<!doctype html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><title>Dockerfile reference | Docker Docs
</title><meta name=description content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta name=keywords content="dockerfile,docker file,docker copy,dockerfile exec,docker entrypoint,dockerfile entrypoint,dockerfile arg,docker args,entrypoint,shell dockerfile"><link rel=canonical href="index.html"><link rel=icon type=image/x-icon href="../../../assets/favicons/docs@2x.ico" sizes=129x128><link rel=apple-touch-icon type=image/x-icon href="../../../assets/favicons/docs@2x.ico" sizes=129x128><meta name=msapplication-TileImage content="https://docs.docker.com/assets/favicons/docs@2x.ico"><meta name=theme-color content="#2496ed"><meta name=twitter:title itemprop="title name" content="Dockerfile reference"><meta name=twitter:description property="og:description" itemprop=description content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta name=twitter:card content="summary_large_image"><meta name=twitter:domain content="https://docs.docker.com"><meta name=twitter:site content="@docker_docs"><meta name=twitter:url content="https://twitter.com/docker_docs"><meta name=twitter:image:src content="https://docs.docker.com/assets/images/thumbnail.webp"><meta name=twitter:image:alt content="Docker Documentation"><meta property="og:title" content="Dockerfile reference"><meta property="og:description" content="Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more."><meta property="og:type" content="website"><meta property="og:updated_time" itemprop=dateUpdated content="2024-02-01 14:58:33 +0100 +0100"><meta property="og:image" itemprop="image primaryImageOfPage" content="https://docs.docker.com/assets/images/thumbnail.webp"><meta property="og:locale" content="en_US"><meta property="og:url" content="https://docs.docker.com/reference/dockerfile/"><meta property="og:site_name" content="Docker Documentation"><meta property="article:published_time" itemprop=datePublished content="2024-02-01 14:58:33 +0100 +0100"><script type=application/ld+json>{"@context":"https://schema.org","@type":"WebPage","headline":"\"Dockerfile reference\"","description":"\"Find all the available commands you can use in a Dockerfile and learn how to use them, including COPY, ARG, ENTRYPOINT, and more.\"","url":"https:\/\/docs.docker.com\/reference\/dockerfile\/"}</script><script src=https://cdn.cookielaw.org/scripttemplates/otSDKStub.js type=text/javascript data-domain-script=8e0ebfd9-035d-4ec2-9b2f-a2de9c09f906></script><script type=text/javascript>function OptanonWrapper(){}</script><script>(function(e,t,n,s,o){e[s]=e[s]||[],e[s].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var a=t.getElementsByTagName(n)[0],i=t.createElement(n),r=s!="dataLayer"?"&l="+s:"";i.async=!0,i.src="https://www.googletagmanager.com/gtm.js?id="+o+r,a.parentNode.insertBefore(i,a)})(window,document,"script","dataLayer","GTM-WL2QLG5")</script><script>(function(e,t,n,s,o,i){e.hj=e.hj||function(){(e.hj.q=e.hj.q||[]).push(arguments)},e._hjSettings={hjid:3169877,hjsv:6},o=t.getElementsByTagName("head")[0],i=t.createElement("script"),i.async=1,i.src=n+e._hjSettings.hjid+s+e._hjSettings.hjsv,o.appendChild(i)})(window,document,"https://static.hotjar.com/c/hotjar-",".js?sv=")</script><link href="../../../assets/fonts/RobotoFlex.woff2" rel=preload as=font type=font/woff2 crossorigin><style>body>img{display:none}</style><link href="../../../css/styles.min.8767cc26123e21700c497beebf1cbd8dfdfec3499469fd8793a873c11b567264.css" rel=stylesheet><script>(()=>{function t(){let e=localStorage.getItem("theme-preference");return e||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}var e=t();document.firstElementChild.className=e==="dark"?"dark":"light",localStorage.setItem("theme-preference",e)})()</script><script defer src="../../../scripts.js"></script><link rel=preconnect href=https://3XRLW0LZH9-dsn.algolia.net crossorigin></head><body class="bg-background-light text-base dark:bg-background-dark dark:text-white"><header class="sticky top-0 z-20 h-16 px-4 text-white bg-gradient-to-r from-accent-light to-blue-light-500 dark:from-accent-dark dark:to-blue-dark-100"><div class="mx-auto flex h-full max-w-[1400px] items-center justify-between"><div class="flex h-full items-center gap-8 md:gap-2"><button x-data @click="() => {
      $store.showSidebar = ! $store.showSidebar;
      const sidebar = document.querySelector('#sidebar');
      if ($store.showSidebar) {
        sidebar.classList.replace('md:hidden', 'md:block');
      } else {
        sidebar.classList.replace('md:block', 'md:hidden');
      }
      }" class="icon-svg hidden px-4 md:block" aria-label=Menu><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M150-240q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T150-3e2h660q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T810-240H150zm0-210q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T150-510h660q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T810-450H150zm0-210q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T150-720h660q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T810-660H150z"/></svg></button><div><a title="Docker Docs home page" href="../../../index.html"><div><svg width="92" height="33" viewBox="0 0 92 33" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M31.4783 13.9171C30.6936 13.3542 28.6325 13.1137 27.1335 13.5441 27.0527 11.9527 26.2826 10.6119 24.8747 9.44209L24.3529 9.06908 24.0051 9.62859C23.3219 10.7333 23.0351 12.2054 23.1366 13.5441 23.2173 14.3684 23.4865 15.2954 24.0051 15.9686 22.0548 17.1748 20.2566 16.9011 12.2938 16.9011H.00279151C-.0334407 18.818.256417 22.505 2.4552 25.5056 2.69847 25.8367 2.96452 26.1578 3.25334 26.4668c1.7878 1.9092 4.48969 3.3085 8.53006 3.313C17.9471 29.7853 23.2277 26.234 26.4399 17.6471 27.4969 17.6659 30.2867 17.8491 31.6522 15.0361 31.6853 14.9886 32 14.2901 32 14.2901L31.4783 13.9171zM8.02461 11.9395H4.56805v3.6848H8.02461V11.9395zm4.46589.0H9.03394v3.6848H12.4905V11.9395zm4.4659.0H13.4998v3.6848h3.4566V11.9395zm4.4659.0H17.9657v3.6848h3.4566V11.9395zm-17.86461.0H.102171v3.6848H3.55873L3.55769 11.9395zM8.02357 7.28461H4.56702V10.9694H8.02357V7.28461zm4.46593.0H9.0329V10.9694h3.4566V7.28461zm4.4658.0H13.4988V10.9694h3.4565V7.28461zm0-4.65485H13.4988V6.31458h3.4565V2.62976z" fill="#fff"/><path d="M78.9658 8.41589C78.4538 8.41589 78.0459 8.81327 78.0459 9.30828 78.0459 9.81422 78.4538 10.2116 78.9658 10.2116 79.4827 10.2116 79.8801 9.81422 79.8801 9.30828 79.8797 8.81327 79.4823 8.41589 78.9658 8.41589zM78.9711 10.0216C78.5685 10.0216 78.2744 9.70606 78.2744 9.30868 78.2744 8.91697 78.5684 8.59575 78.9658 8.59575 79.3628 8.59575 79.6512 8.91697 79.6512 9.31435 79.6512 9.70606 79.3628 10.0216 78.9711 10.0216z" fill="#fff"/><path d="M79.1725 9.33586V9.32492C79.281 9.29211 79.3572 9.21636 79.3572 9.11793 79.3572 9.03083 79.3191 8.95995 79.2701 8.92227 79.2049 8.8842 79.1287 8.85706 78.9598 8.85706 78.8132 8.85706 78.6985 8.86799 78.6171 8.8846V9.77699H78.8241V9.41768H78.9217C79.0364 9.41768 79.0907 9.46143 79.1069 9.55906 79.134 9.66275 79.1502 9.74418 79.1777 9.77699H79.4009C79.3791 9.74418 79.3625 9.68989 79.3357 9.55379 79.3082 9.43348 79.2592 9.36826 79.1725 9.33586zM78.9274 9.27064H78.8298V9.01504C78.8517 9.00937 78.8893 9.0037 78.944 9.0037 79.0749 9.0037 79.1344 9.05838 79.1344 9.14021 79.134 9.23256 79.0416 9.27064 78.9274 9.27064z" fill="#fff"/><path d="M41.5015 10.32C42.47 10.32 43.285 9.9708 43.9785 9.27042 44.6631 8.57936 45.003 7.73518 45.003 6.73747V.752051C45.003.560855 44.9402.400849 44.8122.27568 44.6842.150511 44.5307.0869141 44.3463.0869141 44.158.0869141 44.0041.150511 43.8809.27568 43.7574.400849 43.697.560855 43.697.752051V3.94284C43.0639 3.41949 42.3327 3.15537 41.5015 3.15537 40.5354 3.15537 39.7086 3.50415 39.0244 4.20493 38.3399 4.90288 38 5.74746 38 6.73788 38 7.72829 38.3423 8.57045 39.0244 9.27082 39.7086 9.96877 40.533 10.32 41.5015 10.32zM39.4806 5.86736C39.5948 5.59394 39.7507 5.35778 39.946 5.15524 40.1416 4.9523 40.3746 4.79189 40.6399 4.67198 40.9076 4.55168 41.194 4.49294 41.5035 4.49294S42.0925 4.55168 42.3603 4.67198C42.628 4.79229 42.8585 4.9527 43.0566 5.15767 43.2547 5.36264 43.4106 5.60082 43.5244 5.86979 43.6387 6.1412 43.6966 6.4288 43.6966 6.73545 43.6966 7.04209 43.6383 7.33213 43.5244 7.6011V7.60596C43.4102 7.87736 43.2543 8.11554 43.0566 8.31808 42.8589 8.52346 42.626 8.68346 42.3603 8.80377 42.0925 8.92408 41.8085 8.98281 41.5035 8.98281S40.9076 8.92408 40.6399 8.80377C40.3721 8.68346 40.1416 8.52305 39.946 8.32011 39.7503 8.11716 39.5944 7.87898 39.4806 7.60798 39.3663 7.33456 39.3084 7.04452 39.3084 6.73788 39.308 6.43123 39.3663 6.1412 39.4806 5.86736z" fill="#fff"/><path d="M72.9696 8.97333C72.9696 8.78699 72.9092 8.62212 72.7853 8.49695 72.6621 8.37179 72.5062 8.30819 72.3198 8.30819 72.157 8.31305 72.0124 8.36692 71.8892 8.47548 71.6936 8.64521 71.4817 8.77484 71.2512 8.8599 71.0207 8.94497 70.7692 8.9871 70.4946 8.9871 70.2523 8.9871 70.0194 8.94943 69.7982 8.87165 69.5767 8.79388 69.3701 8.68774 69.1858 8.5484 68.9994 8.40905 68.839 8.24419 68.7017 8.04853 68.5644 7.85531 68.4595 7.64062 68.3898 7.40487H73.3418C73.5253 7.40487 73.6793 7.34127 73.8073 7.2161S73.9981 6.93093 73.9981 6.73973c0-.49541-.0862999999999943-.95517-.256-1.37726C73.5719 4.93795 73.3131 4.55353 72.9736 4.20921L72.9692 4.20678C72.2777 3.50883 71.4509 3.15723 70.4921 3.15723 69.5325 3.15723 68.6993 3.5064 68.0147 4.20678 67.3301 4.90473 66.9902 5.74932 66.9902 6.73973S67.3325 8.5723 68.0147 9.27268C68.6993 9.97062 69.5236 10.3222 70.4921 10.3222 71.372 10.3222 72.1331 10.0322 72.7804 9.45212 72.906 9.31966 72.9696 9.15966 72.9696 8.97333zM68.6924 5.43093C68.8301 5.2377 68.9925 5.07 69.1793 4.93106 69.368 4.79212 69.5726 4.68558 69.7986 4.60781 70.0243 4.53003 70.2547 4.49236 70.4925 4.49236 70.7299 4.49236 70.9604 4.53003 71.1836 4.60781 71.4072 4.68558 71.6126 4.79171 71.7961 4.93106 71.9824 5.07 72.1452 5.23527 72.2826 5.43093 72.4223 5.62415 72.5272 5.83884 72.5997 6.07459H68.3853C68.4526 5.84127 68.555 5.62658 68.6924 5.43093z" fill="#fff"/><path d="M75.3696 10.3222C75.5531 10.3222 75.7026 10.2562 75.8278 10.1265 75.9562 9.99692 76.0186 9.83894 76.0186 9.65747V6.74011c0-.3111.0582999999999885-.60357.1721-.8774C76.305 5.58928 76.4609 5.35312 76.6586 5.15058 76.8571 4.94764 77.0896 4.78723 77.3549 4.67178 77.6227 4.5539 77.9071 4.49476 78.2121 4.49476 78.5167 4.49476 78.8055 4.54904 79.0688 4.65517 79.1733 4.70216 79.2645 4.72606 79.3435 4.72606 79.4346 4.72606 79.5205 4.70945 79.5995 4.67421 79.6785 4.63897 79.7485 4.59157 79.8069 4.53041 79.8652 4.46924 79.9114 4.39835 79.9466 4.31572 79.9814 4.23551 80.0001 4.14842 80.0001 4.05404 80.0001 3.87013 79.9417 3.72147 79.8255 3.60602H79.8279C79.7117 3.49058 79.5646 3.40065 79.3876 3.33462 79.2106 3.26859 79.0174 3.22363 78.8055 3.19771 78.5957 3.17178 78.398 3.16003 78.2145 3.16003 77.7977 3.16003 77.4064 3.22849 77.0386 3.365 76.6708 3.50192 76.3305 3.69757 76.0186 3.95236V3.82517C76.0186 3.64127 75.9558 3.48571 75.8278 3.35568 75.7002 3.22606 75.5487 3.16003 75.3696 3.16003 75.1898 3.16003 75.0318 3.22606 74.9042 3.35568 74.7758 3.48531 74.713 3.64329 74.713 3.82517v5.8323C74.713 9.84137 74.7758 9.99692 74.9042 10.1265 75.0318 10.2562 75.1857 10.3222 75.3696 10.3222z" fill="#fff"/><path d="M52.4904 5.3649C52.3203 4.94281 52.0667 4.55596 51.7244 4.20678 51.0329 3.50883 50.2066 3.15723 49.2473 3.15723 48.2881 3.15723 47.4545 3.5064 46.7703 4.20678 46.0857 4.90473 45.7458 5.74932 45.7458 6.73973S46.0881 8.5723 46.7703 9.27268C47.4549 9.97062 48.2788 10.3222 49.2473 10.3222 50.2159 10.3222 51.0309 9.97305 51.7244 9.27268 52.409 8.58161 52.7488 7.73743 52.7488 6.73973 52.744 6.24472 52.6581 5.78699 52.4904 5.3649zM51.2703 7.60052V7.60538C51.1561 7.87678 51.0001 8.11497 50.8024 8.31751 50.6043 8.52288 50.3718 8.68288 50.1061 8.80319 49.8408 8.9235 49.5544 8.98224 49.2494 8.98224 48.9443 8.98224 48.6535 8.9235 48.3857 8.80319 48.118 8.68288 47.8875 8.52247 47.6918 8.31953 47.4962 8.11659 47.3402 7.8784 47.2264 7.6074 47.1122 7.33398 47.0543 7.04394 47.0543 6.7373 47.0543 6.43066 47.1126 6.14062 47.2264 5.86719 47.3406 5.59376 47.4966 5.35761 47.6918 5.15507 47.8875 4.95212 48.1204 4.79171 48.3857 4.67181 48.6535 4.5515 48.9399 4.49276 49.2494 4.49276 49.5588 4.49276 49.8383 4.5515 50.1061 4.67181S50.6043 4.95253 50.8024 5.1575C51.0005 5.36247 51.1565 5.60065 51.2703 5.86962 51.3845 6.14102 51.4425 6.42863 51.4425 6.73527 51.4429 7.04192 51.3845 7.33195 51.2703 7.60052z" fill="#fff"/><path d="M63.628 6.08918 66.2472 4.34856C66.4141 4.23352 66.4955 4.05731 66.4963 3.82034 66.4959 3.73163 66.4777 3.64737 66.4428 3.56798 66.408 3.48777 66.3614 3.41486 66.3031 3.35328 66.2448 3.29212 66.1751 3.24229 66.0957 3.20948 66.0167 3.17667 65.9304 3.15763 65.8397 3.15763 65.7092 3.15763 65.593 3.19085 65.4905 3.2589L61.7516 5.74689V.75674C61.7516.567974 61.6889.409993 61.5609.280369 61.4329.150744 61.2814.0847168 61.1023.0847168 60.9233.0847168 60.7649.150744 60.6365.280369 60.5085.409993 60.4457.567974 60.4457.75674V9.64778C60.4457 9.83168 60.5085 9.98966 60.6365 10.1217 60.7645 10.2538 60.9184 10.3198 61.1023 10.3198S61.4353 10.2538 61.5609 10.1217C61.6889 9.98966 61.7516 9.83168 61.7516 9.64778V7.33884L62.5152 6.82723l2.8894 3.31797C65.5209 10.2607 65.6675 10.3174 65.8421 10.3174 65.9329 10.3174 66.0191 10.3008 66.0981 10.2655 66.1771 10.2323 66.2472 10.1829 66.3055 10.1217 66.3639 10.0606 66.4104 9.98966 66.4453 9.90703 66.4801 9.82682 66.4987 9.73973 66.4987 9.65223 66.4987 9.47764 66.4384 9.3221 66.3173 9.18518l-2.6893-3.096z" fill="#fff"/><path d="M56.9841 10.3247C57.8595 10.3247 58.621 10.0346 59.2659 9.45457 59.4032 9.31319 59.4733 9.15035 59.4733 8.96159 59.4733 8.77282 59.4126 8.60998 59.2894 8.48522 59.1659 8.36005 59.0099 8.29645 58.824 8.29645 58.6656 8.30131 58.5283 8.3483 58.412 8.43782 58.2026 8.62173 57.9838 8.75864 57.7485 8.8506 57.5156 8.94255 57.262 8.98751 56.9849 8.98751 56.6799 8.98751 56.3959 8.92837 56.1282 8.81049 55.8604 8.69262 55.6275 8.53221 55.4274 8.33169 55.2273 8.13118 55.0689 7.89056 54.9547 7.61957 54.8404 7.34614 54.7825 7.05368 54.7825 6.74217 54.7825 6.43067 54.8409 6.1386 54.9547 5.86477 55.0689 5.59135 55.2269 5.35519 55.4274 5.15265V5.15022C55.6275 4.94727 55.8604 4.78686 56.1282 4.67142 56.3959 4.55354 56.6799 4.4944 56.9849 4.4944 57.2596 4.4944 57.5136 4.54139 57.7485 4.63577 57.9814 4.73015 58.205 4.86909 58.4165 5.05097 58.542 5.15224 58.6842 5.20409 58.8426 5.20409 59.0314 5.20409 59.1849 5.1405 59.3084 5.0133 59.432 4.88611 59.4924 4.7257 59.4924 4.5345 59.4924 4.34371 59.4178 4.16669 59.2663 4.02977 58.6239 3.4497 57.8623 3.15967 56.9845 3.15967c-.966099999999997.0-1.7929.34917-2.477 1.04955C53.8229 4.90717 53.483 5.75135 53.483 6.74217 53.483 7.73258 53.8253 8.57474 54.5075 9.27512 55.1912 9.97306 56.0156 10.3247 56.9841 10.3247z" fill="#fff"/><path d="M44.774 32.4167C43.578 32.4167 42.497 32.1407 41.531 31.5887 40.5803 31.0214 39.8213 30.2547 39.254 29.2887 38.702 28.3227 38.426 27.234 38.426 26.0227s.253-2.2923.759-3.243C39.7063 21.8137 40.4117 21.0547 41.301 20.5027 42.1903 19.9354 43.1947 19.6517 44.314 19.6517 45.2187 19.6517 46.0543 19.8434 46.821 20.2267 47.5877 20.5947 48.2317 21.1007 48.753 21.7447v-6.21C48.753 15.182 48.8603 14.8984 49.075 14.6837 49.305 14.469 49.5887 14.3617 49.926 14.3617 50.2787 14.3617 50.5623 14.469 50.777 14.6837S51.099 15.182 51.099 15.5347v10.488C51.099 27.234 50.8153 28.3227 50.248 29.2887 49.696 30.2547 48.9447 31.0214 47.994 31.5887 47.0433 32.1407 45.97 32.4167 44.774 32.4167zm0-2.07C45.556 30.3467 46.2537 30.1627 46.867 29.7947 47.4803 29.4114 47.9633 28.89 48.316 28.2307 48.6687 27.5714 48.845 26.8354 48.845 26.0227 48.845 25.1947 48.6687 24.4587 48.316 23.8147 47.9633 23.1707 47.4803 22.6647 46.867 22.2967 46.2537 21.9134 45.556 21.7217 44.774 21.7217 44.0073 21.7217 43.3097 21.9134 42.681 22.2967 42.0677 22.6647 41.577 23.1707 41.209 23.8147 40.8563 24.4587 40.68 25.1947 40.68 26.0227 40.68 26.8354 40.8563 27.5714 41.209 28.2307 41.577 28.89 42.0677 29.4114 42.681 29.7947 43.3097 30.1627 44.0073 30.3467 44.774 30.3467zm15.1719 2.07c-1.242.0-2.3384-.268299999999996-3.289-.805-.950699999999998-.552-1.702-1.3033-2.254-2.254C53.8662 28.3917 53.5979 27.2877 53.5979 26.0457c0-1.2573.268299999999996-2.3613.805-3.312.552-.965999999999998 1.3033-1.7173 2.254-2.254C57.6075 19.9277 58.7039 19.6517 59.9459 19.6517c1.2266.0 2.3153.276 3.266.827999999999999C64.1625 21.0164 64.9062 21.7677 65.4429 22.7337 65.9949 23.6844 66.2709 24.7884 66.2709 26.0457c0 1.242-.2684 2.346-.804999999999993 3.312C64.9292 30.3084 64.1855 31.0597 63.2349 31.6117 62.2842 32.1484 61.1879 32.4167 59.9459 32.4167zm0-2.07c.7973.0 1.5026-.183999999999998 2.116-.552C62.6752 29.4267 63.1505 28.9207 63.4879 28.2767 63.8405 27.6327 64.0169 26.889 64.0169 26.0457S63.8405 24.4587 63.4879 23.8147C63.1505 23.1554 62.6752 22.6417 62.0619 22.2737 61.4485 21.9057 60.7432 21.7217 59.9459 21.7217 59.1485 21.7217 58.4432 21.9057 57.8299 22.2737 57.2165 22.6417 56.7335 23.1554 56.3809 23.8147 56.0282 24.4587 55.8519 25.2024 55.8519 26.0457S56.0282 27.6327 56.3809 28.2767C56.7335 28.9207 57.2165 29.4267 57.8299 29.7947 58.4432 30.1627 59.1485 30.3467 59.9459 30.3467zm14.5205 2.07C73.2397 32.4167 72.1434 32.1407 71.1774 31.5887 70.2267 31.0214 69.4754 30.2624 68.9234 29.3117 68.3867 28.3457 68.1184 27.257 68.1184 26.0457 68.1184 24.8037 68.3867 23.6997 68.9234 22.7337 69.46 21.7677 70.196 21.0164 71.1314 20.4797 72.0667 19.9277 73.14 19.6517 74.3514 19.6517 75.256 19.6517 76.084 19.828 76.8354 20.1807 77.5867 20.518 78.2614 21.0317 78.8594 21.7217 79.0741 21.967 79.1507 22.22 79.0894 22.4807S78.8594 22.9714 78.5834 23.1707C78.3687 23.324 78.1311 23.3777 77.8704 23.3317 77.6097 23.2704 77.372 23.1324 77.1574 22.9177 76.406 22.1204 75.4707 21.7217 74.3514 21.7217 73.5694 21.7217 72.8794 21.9057 72.2814 22.2737 71.6834 22.6264 71.2157 23.1247 70.8784 23.7687 70.541 24.4127 70.3724 25.1717 70.3724 26.0457 70.3724 26.8737 70.541 27.6097 70.8784 28.2537 71.231 28.8977 71.714 29.4114 72.3274 29.7947 72.9407 30.1627 73.6537 30.3467 74.4664 30.3467 75.0031 30.3467 75.4707 30.2854 75.8694 30.1627 76.2834 30.0247 76.6591 29.8177 76.9964 29.5417 77.2417 29.3424 77.4947 29.235 77.7554 29.2197 78.0161 29.189 78.2461 29.258 78.4454 29.4267 78.706 29.6414 78.8517 29.8867 78.8824 30.1627 78.913 30.4234 78.821 30.661 78.6064 30.8757 77.5024 31.903 76.1224 32.4167 74.4664 32.4167zm11.6865.0C85.0795 32.4167 84.0829 32.2557 83.1629 31.9337 82.2582 31.5964 81.5529 31.1747 81.0469 30.6687 80.8169 30.4234 80.7172 30.1474 80.7479 29.8407 80.7939 29.5187 80.9472 29.258 81.2079 29.0587 81.5145 28.8134 81.8135 28.7137 82.1049 28.7597 82.4115 28.7904 82.6722 28.9207 82.8869 29.1507 83.1475 29.442 83.5615 29.718 84.1289 29.9787 84.7115 30.224 85.3555 30.3467 86.0609 30.3467 86.9502 30.3467 87.6249 30.201 88.0849 29.9097 88.5602 29.6184 88.8055 29.2427 88.8209 28.7827 88.8362 28.3227 88.6139 27.924 88.1539 27.5867 87.7092 27.2494 86.8889 26.9734 85.6929 26.7587 84.1442 26.452 83.0172 25.992 82.3119 25.3787 81.6219 24.7654 81.2769 24.014 81.2769 23.1247 81.2769 22.3427 81.5069 21.6987 81.9669 21.1927 82.4269 20.6714 83.0172 20.288 83.7379 20.0427 84.4585 19.782 85.2099 19.6517 85.9919 19.6517 87.0039 19.6517 87.9009 19.8127 88.6829 20.1347 89.4649 20.4567 90.0859 20.9014 90.5459 21.4687 90.7605 21.714 90.8602 21.9747 90.8449 22.2507 90.8295 22.5114 90.6992 22.7337 90.4539 22.9177 90.2085 23.0864 89.9172 23.14 89.5799 23.0787 89.2425 23.0174 88.9589 22.8794 88.7289 22.6647 88.3455 22.2967 87.9315 22.0437 87.4869 21.9057 87.0422 21.7677 86.5285 21.6987 85.9459 21.6987 85.2712 21.6987 84.6962 21.8137 84.2209 22.0437 83.7609 22.2737 83.5309 22.611 83.5309 23.0557 83.5309 23.3317 83.5999 23.5847 83.7379 23.8147 83.8912 24.0294 84.1825 24.2287 84.6119 24.4127 85.0412 24.5814 85.6699 24.75 86.4979 24.9187 87.6479 25.1487 88.5525 25.44 89.2119 25.7927 89.8865 26.1454 90.3695 26.5594 90.6609 27.0347 90.9522 27.4947 91.0979 28.0314 91.0979 28.6447 91.0979 29.35 90.9062 29.9864 90.5229 30.5537 90.1549 31.121 89.6029 31.5734 88.8669 31.9107 88.1462 32.248 87.2415 32.4167 86.1529 32.4167z" fill="#fff"/></svg></div></a></div><div><nav><ul class="box-content flex mt-1 gap-4 md:hidden"><li><a class="block py-1 px-2" href="../../../get-started/overview/index.html">Guides</a></li><li><a class="block py-1 px-2" href="../../../manuals/index.html">Manuals</a></li><li class=border-b-4><a class="block py-1 px-2" href="../../../app/working-with-app/index.html">Reference</a></li><li><a class="block py-1 px-2" href="../../../samples/index.html">Samples</a></li><li><a class="block py-1 px-2" href="../../../faq/index.html">FAQ</a></li></ul></nav></div></div><div class="flex items-center gap-6"><div id=docsearch></div><button aria-label="Theme switch" id=theme-switch class=svg-icon x-data="{ theme: localStorage.getItem('theme-preference') }" x-init="$watch('theme', value => {
        localStorage.setItem('theme-preference', value);
        document.firstElementChild.className = value;
      })" @click="theme = (theme === 'dark' ? 'light' : 'dark')">
<span class="icon-svg dark:hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-280q-83 0-141.5-58.5T280-480t58.5-141.5T480-680t141.5 58.5T680-480t-58.5 141.5T480-280zM70-450q-12.75.0-21.375-8.675Q40-467.351 40-480.175 40-493 48.625-501.5T70-510h1e2q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T170-450H70zm720 0q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T790-510h1e2q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T890-450H790zM479.825-760Q467-760 458.5-768.625T450-790v-1e2q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T510-890v1e2q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625zm0 720Q467-40 458.5-48.625T450-70v-1e2q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T510-170v1e2q0 12.75-8.675 21.375Q492.649-40 479.825-40zM240-678l-57-56q-9-9-8.629-21.603.37-12.604 8.526-21.5 8.896-8.897 21.5-8.897Q217-786 226-777l56 57q8 9 8 21t-8 20.5-20.5 8.5-21.5-8zm494 495-56-57q-8-9-8-21.375T678.5-282q8.5-9 20.5-9t21 9l57 56q9 9 8.629 21.603-.37 12.604-8.526 21.5-8.896 8.897-21.5 8.897Q743-174 734-183zm-56-495q-9-9-9-21t9-21l56-57q9-9 21.603-8.629 12.604.37 21.5 8.526 8.897 8.896 8.897 21.5Q786-743 777-734l-57 56q-8 8-20.364 8-12.363.0-21.636-8zM182.897-182.897q-8.897-8.896-8.897-21.5Q174-217 183-226l57-56q8.8-9 20.9-9 12.1.0 20.709 9Q291-273 291-261t-9 21l-56 57q-9 9-21.603 8.629-12.604-.37-21.5-8.526z"/></svg></span>
<span class="icon-svg hidden dark:block"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-120q-150 0-255-105T120-480q0-135 79.5-229T408-830q20-5 34-1t22 15q8 10 7.5 25t-8.5 35q-9 23-14 47t-5 49q0 90 63 153t153 63q25 0 48.5-4.5T754-461t38-7 26 9 13 23-2 36q-27 121-121 200.5T480-120z"/></svg></span></button></div></div></header><main class=flex><div id=sidebar class="sticky top-16 flex h-screen shrink-0 grow flex-row-reverse overflow-y-scroll bg-background-light dark:bg-gray-dark-100 md:fixed md:z-10 md:hidden md:h-screen md:w-screen lg:grow-0"><nav class="text-sm py-4 hidden gap-4 pl-4 md:flex flex-col justify-evenly"><div class="text-gray-light dark:text-gray-dark">Main sections</div><div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75"><a href="../../../get-started/overview/index.html">Guides</a></div><div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75"><a href="../../../manuals/index.html">Manuals</a></div><div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75
underline"><a href="../../../app/working-with-app/index.html">Reference</a></div><div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75"><a href="../../../samples/index.html">Samples</a></div><div class="pl-2 underline-offset-8 decoration-2 hover:underline decoration-blue-light dark:decoration-blue-dark hover:opacity-75"><a href="../../../faq/index.html">FAQ</a></div></nav><hr><nav id=sectiontree class="text-sm w-[300px] md:w-full flex flex-col"><div class="hidden md:block p-4 text-gray-light dark:text-gray-dark">This section</div><ul><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../app/working-with-app/index.html" title="Reference documentation"><span class="flex items-center gap-2">Reference documentation</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">CLI reference
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/index.html" title="docker (base command)"><span class="flex items-center gap-2">docker (base command)</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/build/index.html" title="docker build"><span class="flex items-center gap-2">docker build</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker builder
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/builder/index.html" title="docker builder"><span class="flex items-center gap-2">docker builder</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/builder/build/index.html" title="docker builder build"><span class="flex items-center gap-2">docker builder build</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/builder/prune/index.html" title="docker builder prune"><span class="flex items-center gap-2">docker builder prune</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker buildx
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/index.html" title="docker buildx"><span class="flex items-center gap-2">docker buildx</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/bake/index.html" title="docker buildx bake"><span class="flex items-center gap-2">docker buildx bake</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../commandline/buildx_build/index.html" title="docker buildx build"><span class="flex items-center gap-2">docker buildx build</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/create/index.html" title="docker buildx create"><span class="flex items-center gap-2">docker buildx create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/debug/index.html" title="docker buildx debug"><span class="flex items-center gap-2">docker buildx debug</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/debug/build/index.html" title="docker buildx debug build"><span class="flex items-center gap-2">docker buildx debug build</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/du/index.html" title="docker buildx du"><span class="flex items-center gap-2">docker buildx du</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/imagetools/index.html" title="docker buildx imagetools"><span class="flex items-center gap-2">docker buildx imagetools</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/imagetools/create/index.html" title="docker buildx imagetools create"><span class="flex items-center gap-2">docker buildx imagetools create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/imagetools/inspect/index.html" title="docker buildx imagetools inspect"><span class="flex items-center gap-2">docker buildx imagetools inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/inspect/index.html" title="docker buildx inspect"><span class="flex items-center gap-2">docker buildx inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/ls/index.html" title="docker buildx ls"><span class="flex items-center gap-2">docker buildx ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/prune/index.html" title="docker buildx prune"><span class="flex items-center gap-2">docker buildx prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/rm/index.html" title="docker buildx rm"><span class="flex items-center gap-2">docker buildx rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/stop/index.html" title="docker buildx stop"><span class="flex items-center gap-2">docker buildx stop</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/use/index.html" title="docker buildx use"><span class="flex items-center gap-2">docker buildx use</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/buildx/version/index.html" title="docker buildx version"><span class="flex items-center gap-2">docker buildx version</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker checkpoint
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/checkpoint/index.html" title="docker checkpoint"><span class="flex items-center gap-2">docker checkpoint</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/checkpoint/create/index.html" title="docker checkpoint create"><span class="flex items-center gap-2">docker checkpoint create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/checkpoint/ls/index.html" title="docker checkpoint ls"><span class="flex items-center gap-2">docker checkpoint ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/checkpoint/rm/index.html" title="docker checkpoint rm"><span class="flex items-center gap-2">docker checkpoint rm</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker compose
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/reference/index.html" title=overview><span class="flex items-center gap-2">overview</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/alpha/index.html" title="docker compose alpha"><span class="flex items-center gap-2">docker compose alpha</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/alpha/dry-run/index.html" title="docker compose alpha dry-run"><span class="flex items-center gap-2">docker compose alpha dry-run</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/alpha/publish/index.html" title="docker compose alpha publish"><span class="flex items-center gap-2">docker compose alpha publish</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/alpha/scale/index.html" title="docker compose alpha scale"><span class="flex items-center gap-2">docker compose alpha scale</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/alpha/viz/index.html" title="docker compose alpha viz"><span class="flex items-center gap-2">docker compose alpha viz</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/index.html" title="docker compose"><span class="flex items-center gap-2">docker compose</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/build/index.html" title="docker compose build"><span class="flex items-center gap-2">docker compose build</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/config/index.html" title="docker compose config"><span class="flex items-center gap-2">docker compose config</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/cp/index.html" title="docker compose cp"><span class="flex items-center gap-2">docker compose cp</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/create/index.html" title="docker compose create"><span class="flex items-center gap-2">docker compose create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/down/index.html" title="docker compose down"><span class="flex items-center gap-2">docker compose down</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/events/index.html" title="docker compose events"><span class="flex items-center gap-2">docker compose events</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/exec/index.html" title="docker compose exec"><span class="flex items-center gap-2">docker compose exec</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/images/index.html" title="docker compose images"><span class="flex items-center gap-2">docker compose images</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/kill/index.html" title="docker compose kill"><span class="flex items-center gap-2">docker compose kill</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/logs/index.html" title="docker compose logs"><span class="flex items-center gap-2">docker compose logs</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/ls/index.html" title="docker compose ls"><span class="flex items-center gap-2">docker compose ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/pause/index.html" title="docker compose pause"><span class="flex items-center gap-2">docker compose pause</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/port/index.html" title="docker compose port"><span class="flex items-center gap-2">docker compose port</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/ps/index.html" title="docker compose ps"><span class="flex items-center gap-2">docker compose ps</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/pull/index.html" title="docker compose pull"><span class="flex items-center gap-2">docker compose pull</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/push/index.html" title="docker compose push"><span class="flex items-center gap-2">docker compose push</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/restart/index.html" title="docker compose restart"><span class="flex items-center gap-2">docker compose restart</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/rm/index.html" title="docker compose rm"><span class="flex items-center gap-2">docker compose rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/run/index.html" title="docker compose run"><span class="flex items-center gap-2">docker compose run</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/start/index.html" title="docker compose start"><span class="flex items-center gap-2">docker compose start</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/stop/index.html" title="docker compose stop"><span class="flex items-center gap-2">docker compose stop</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/top/index.html" title="docker compose top"><span class="flex items-center gap-2">docker compose top</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/unpause/index.html" title="docker compose unpause"><span class="flex items-center gap-2">docker compose unpause</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/up/index.html" title="docker compose up"><span class="flex items-center gap-2">docker compose up</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/version/index.html" title="docker compose version"><span class="flex items-center gap-2">docker compose version</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/wait/index.html" title="docker compose wait"><span class="flex items-center gap-2">docker compose wait</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/compose/watch/index.html" title="docker compose watch"><span class="flex items-center gap-2">docker compose watch</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker config
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/config/index.html" title="docker config"><span class="flex items-center gap-2">docker config</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/config/create/index.html" title="docker config create"><span class="flex items-center gap-2">docker config create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/config/inspect/index.html" title="docker config inspect"><span class="flex items-center gap-2">docker config inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/config/ls/index.html" title="docker config ls"><span class="flex items-center gap-2">docker config ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/config/rm/index.html" title="docker config rm"><span class="flex items-center gap-2">docker config rm</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker container
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/index.html" title="docker container"><span class="flex items-center gap-2">docker container</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/attach/index.html" title="docker container attach"><span class="flex items-center gap-2">docker container attach</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/commit/index.html" title="docker container commit"><span class="flex items-center gap-2">docker container commit</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/cp/index.html" title="docker container cp"><span class="flex items-center gap-2">docker container cp</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/create/index.html" title="docker container create"><span class="flex items-center gap-2">docker container create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/diff/index.html" title="docker container diff"><span class="flex items-center gap-2">docker container diff</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/exec/index.html" title="docker container exec"><span class="flex items-center gap-2">docker container exec</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/export/index.html" title="docker container export"><span class="flex items-center gap-2">docker container export</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/inspect/index.html" title="docker container inspect"><span class="flex items-center gap-2">docker container inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/kill/index.html" title="docker container kill"><span class="flex items-center gap-2">docker container kill</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/logs/index.html" title="docker container logs"><span class="flex items-center gap-2">docker container logs</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/ps/index.html" title="docker container ls"><span class="flex items-center gap-2">docker container ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/pause/index.html" title="docker container pause"><span class="flex items-center gap-2">docker container pause</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/port/index.html" title="docker container port"><span class="flex items-center gap-2">docker container port</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/prune/index.html" title="docker container prune"><span class="flex items-center gap-2">docker container prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/rename/index.html" title="docker container rename"><span class="flex items-center gap-2">docker container rename</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/restart/index.html" title="docker container restart"><span class="flex items-center gap-2">docker container restart</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/rm/index.html" title="docker container rm"><span class="flex items-center gap-2">docker container rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../commandline/run/index.html" title="docker container run"><span class="flex items-center gap-2">docker container run</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/start/index.html" title="docker container start"><span class="flex items-center gap-2">docker container start</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/stats/index.html" title="docker container stats"><span class="flex items-center gap-2">docker container stats</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/stop/index.html" title="docker container stop"><span class="flex items-center gap-2">docker container stop</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/top/index.html" title="docker container top"><span class="flex items-center gap-2">docker container top</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/unpause/index.html" title="docker container unpause"><span class="flex items-center gap-2">docker container unpause</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/update/index.html" title="docker container update"><span class="flex items-center gap-2">docker container update</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/container/wait/index.html" title="docker container wait"><span class="flex items-center gap-2">docker container wait</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker context
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/index.html" title="docker context"><span class="flex items-center gap-2">docker context</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/create/index.html" title="docker context create"><span class="flex items-center gap-2">docker context create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/export/index.html" title="docker context export"><span class="flex items-center gap-2">docker context export</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/import/index.html" title="docker context import"><span class="flex items-center gap-2">docker context import</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/inspect/index.html" title="docker context inspect"><span class="flex items-center gap-2">docker context inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/ls/index.html" title="docker context ls"><span class="flex items-center gap-2">docker context ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/rm/index.html" title="docker context rm"><span class="flex items-center gap-2">docker context rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/show/index.html" title="docker context show"><span class="flex items-center gap-2">docker context show</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/update/index.html" title="docker context update"><span class="flex items-center gap-2">docker context update</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/context/use/index.html" title="docker context use"><span class="flex items-center gap-2">docker context use</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/debug/index.html" title="docker debug (Beta)"><span class="flex items-center gap-2">docker debug (Beta)</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/exec/index.html" title="docker exec"><span class="flex items-center gap-2">docker exec</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker image
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/index.html" title="docker image"><span class="flex items-center gap-2">docker image</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/builder/build/index.html" title="docker image build"><span class="flex items-center gap-2">docker image build</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/history/index.html" title="docker image history"><span class="flex items-center gap-2">docker image history</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/import/index.html" title="docker image import"><span class="flex items-center gap-2">docker image import</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/inspect/index.html" title="docker image inspect"><span class="flex items-center gap-2">docker image inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/load/index.html" title="docker image load"><span class="flex items-center gap-2">docker image load</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/images/index.html" title="docker image ls"><span class="flex items-center gap-2">docker image ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/prune/index.html" title="docker image prune"><span class="flex items-center gap-2">docker image prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/pull/index.html" title="docker image pull"><span class="flex items-center gap-2">docker image pull</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/push/index.html" title="docker image push"><span class="flex items-center gap-2">docker image push</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/rm/index.html" title="docker image rm"><span class="flex items-center gap-2">docker image rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/save/index.html" title="docker image save"><span class="flex items-center gap-2">docker image save</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/image/tag/index.html" title="docker image tag"><span class="flex items-center gap-2">docker image tag</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/images/index.html" title="docker images"><span class="flex items-center gap-2">docker images</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/info/index.html" title="docker info"><span class="flex items-center gap-2">docker info</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/init/index.html" title="docker init"><span class="flex items-center gap-2">docker init</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/inspect/index.html" title="docker inspect"><span class="flex items-center gap-2">docker inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/login/index.html" title="docker login"><span class="flex items-center gap-2">docker login</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/logout/index.html" title="docker logout"><span class="flex items-center gap-2">docker logout</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker manifest
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/index.html" title="docker manifest"><span class="flex items-center gap-2">docker manifest</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/annotate/index.html" title="docker manifest annotate"><span class="flex items-center gap-2">docker manifest annotate</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/create/index.html" title="docker manifest create"><span class="flex items-center gap-2">docker manifest create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/inspect/index.html" title="docker manifest inspect"><span class="flex items-center gap-2">docker manifest inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/push/index.html" title="docker manifest push"><span class="flex items-center gap-2">docker manifest push</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/manifest/rm/index.html" title="docker manifest rm"><span class="flex items-center gap-2">docker manifest rm</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker network
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/index.html" title="docker network"><span class="flex items-center gap-2">docker network</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/connect/index.html" title="docker network connect"><span class="flex items-center gap-2">docker network connect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/create/index.html" title="docker network create"><span class="flex items-center gap-2">docker network create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/disconnect/index.html" title="docker network disconnect"><span class="flex items-center gap-2">docker network disconnect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/inspect/index.html" title="docker network inspect"><span class="flex items-center gap-2">docker network inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/ls/index.html" title="docker network ls"><span class="flex items-center gap-2">docker network ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/prune/index.html" title="docker network prune"><span class="flex items-center gap-2">docker network prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/network/rm/index.html" title="docker network rm"><span class="flex items-center gap-2">docker network rm</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker node
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/index.html" title="docker node"><span class="flex items-center gap-2">docker node</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/demote/index.html" title="docker node demote"><span class="flex items-center gap-2">docker node demote</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/inspect/index.html" title="docker node inspect"><span class="flex items-center gap-2">docker node inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/ls/index.html" title="docker node ls"><span class="flex items-center gap-2">docker node ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/promote/index.html" title="docker node promote"><span class="flex items-center gap-2">docker node promote</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/ps/index.html" title="docker node ps"><span class="flex items-center gap-2">docker node ps</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/rm/index.html" title="docker node rm"><span class="flex items-center gap-2">docker node rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/node/update/index.html" title="docker node update"><span class="flex items-center gap-2">docker node update</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker plugin
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/index.html" title="docker plugin"><span class="flex items-center gap-2">docker plugin</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/create/index.html" title="docker plugin create"><span class="flex items-center gap-2">docker plugin create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/disable/index.html" title="docker plugin disable"><span class="flex items-center gap-2">docker plugin disable</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/enable/index.html" title="docker plugin enable"><span class="flex items-center gap-2">docker plugin enable</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/inspect/index.html" title="docker plugin inspect"><span class="flex items-center gap-2">docker plugin inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/install/index.html" title="docker plugin install"><span class="flex items-center gap-2">docker plugin install</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/ls/index.html" title="docker plugin ls"><span class="flex items-center gap-2">docker plugin ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/rm/index.html" title="docker plugin rm"><span class="flex items-center gap-2">docker plugin rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/set/index.html" title="docker plugin set"><span class="flex items-center gap-2">docker plugin set</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/plugin/upgrade/index.html" title="docker plugin upgrade"><span class="flex items-center gap-2">docker plugin upgrade</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/ps/index.html" title="docker ps"><span class="flex items-center gap-2">docker ps</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/pull/index.html" title="docker pull"><span class="flex items-center gap-2">docker pull</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/push/index.html" title="docker push"><span class="flex items-center gap-2">docker push</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/run/index.html" title="docker run"><span class="flex items-center gap-2">docker run</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker scout
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/index.html" title="docker scout"><span class="flex items-center gap-2">docker scout</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/attestation/index.html" title="docker scout attestation"><span class="flex items-center gap-2">docker scout attestation</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/attestation/add/index.html" title="docker scout attestation add"><span class="flex items-center gap-2">docker scout attestation add</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/cache/index.html" title="docker scout cache"><span class="flex items-center gap-2">docker scout cache</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/cache/df/index.html" title="docker scout cache df"><span class="flex items-center gap-2">docker scout cache df</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/cache/prune/index.html" title="docker scout cache prune"><span class="flex items-center gap-2">docker scout cache prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/compare/index.html" title="docker scout compare"><span class="flex items-center gap-2">docker scout compare</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/config/index.html" title="docker scout config"><span class="flex items-center gap-2">docker scout config</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/cves.html" title="docker scout cves"><span class="flex items-center gap-2">docker scout cves</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/enroll/index.html" title="docker scout enroll"><span class="flex items-center gap-2">docker scout enroll</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/environment/index.html" title="docker scout environment"><span class="flex items-center gap-2">docker scout environment</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/integration/index.html" title="docker scout integration"><span class="flex items-center gap-2">docker scout integration</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/integration/configure/index.html" title="docker scout integration configure"><span class="flex items-center gap-2">docker scout integration configure</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/integration/delete/index.html" title="docker scout integration delete"><span class="flex items-center gap-2">docker scout integration delete</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/integration/list/index.html" title="docker scout integration list"><span class="flex items-center gap-2">docker scout integration list</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/policy/index.html" title="docker scout policy"><span class="flex items-center gap-2">docker scout policy</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/quickview/index.html" title="docker scout quickview"><span class="flex items-center gap-2">docker scout quickview</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/recommendations/index.html" title="docker scout recommendations"><span class="flex items-center gap-2">docker scout recommendations</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/repo/index.html" title="docker scout repo"><span class="flex items-center gap-2">docker scout repo</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/repo/disable/index.html" title="docker scout repo disable"><span class="flex items-center gap-2">docker scout repo disable</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/repo/enable.html" title="docker scout repo enable"><span class="flex items-center gap-2">docker scout repo enable</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/repo/list/index.html" title="docker scout repo list"><span class="flex items-center gap-2">docker scout repo list</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/sbom/index.html" title="docker scout sbom"><span class="flex items-center gap-2">docker scout sbom</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/stream/index.html" title="docker scout stream"><span class="flex items-center gap-2">docker scout stream</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/version/index.html" title="docker scout version"><span class="flex items-center gap-2">docker scout version</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/scout/watch/index.html" title="docker scout watch"><span class="flex items-center gap-2">docker scout watch</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/search/index.html" title="docker search"><span class="flex items-center gap-2">docker search</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker secret
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/secret/index.html" title="docker secret"><span class="flex items-center gap-2">docker secret</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/secret/create/index.html" title="docker secret create"><span class="flex items-center gap-2">docker secret create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/secret/inspect/index.html" title="docker secret inspect"><span class="flex items-center gap-2">docker secret inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/secret/ls/index.html" title="docker secret ls"><span class="flex items-center gap-2">docker secret ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/secret/rm/index.html" title="docker secret rm"><span class="flex items-center gap-2">docker secret rm</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker service
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/index.html" title="docker service"><span class="flex items-center gap-2">docker service</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/create/index.html" title="docker service create"><span class="flex items-center gap-2">docker service create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/inspect/index.html" title="docker service inspect"><span class="flex items-center gap-2">docker service inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/logs/index.html" title="docker service logs"><span class="flex items-center gap-2">docker service logs</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/ls/index.html" title="docker service ls"><span class="flex items-center gap-2">docker service ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/ps/index.html" title="docker service ps"><span class="flex items-center gap-2">docker service ps</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/rollback/index.html" title="docker service rollback"><span class="flex items-center gap-2">docker service rollback</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/rm/index.html" title="docker service rm"><span class="flex items-center gap-2">docker service rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/scale/index.html" title="docker service scale"><span class="flex items-center gap-2">docker service scale</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/service/update/index.html" title="docker service update"><span class="flex items-center gap-2">docker service update</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker stack
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/index.html" title="docker stack"><span class="flex items-center gap-2">docker stack</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/config/index.html" title="docker stack config"><span class="flex items-center gap-2">docker stack config</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/deploy/index.html" title="docker stack deploy"><span class="flex items-center gap-2">docker stack deploy</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/ls/index.html" title="docker stack ls"><span class="flex items-center gap-2">docker stack ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/ps/index.html" title="docker stack ps"><span class="flex items-center gap-2">docker stack ps</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/rm/index.html" title="docker stack rm"><span class="flex items-center gap-2">docker stack rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/stack/services/index.html" title="docker stack services"><span class="flex items-center gap-2">docker stack services</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker swarm
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/index.html" title="docker swarm"><span class="flex items-center gap-2">docker swarm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/ca/index.html" title="docker swarm ca"><span class="flex items-center gap-2">docker swarm ca</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/init/index.html" title="docker swarm init"><span class="flex items-center gap-2">docker swarm init</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/join-token/index.html" title="docker swarm join-token"><span class="flex items-center gap-2">docker swarm join-token</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/join/index.html" title="docker swarm join"><span class="flex items-center gap-2">docker swarm join</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/leave/index.html" title="docker swarm leave"><span class="flex items-center gap-2">docker swarm leave</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/unlock-key/index.html" title="docker swarm unlock-key"><span class="flex items-center gap-2">docker swarm unlock-key</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/unlock/index.html" title="docker swarm unlock"><span class="flex items-center gap-2">docker swarm unlock</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/swarm/update/index.html" title="docker swarm update"><span class="flex items-center gap-2">docker swarm update</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker system
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/system/index.html" title="docker system"><span class="flex items-center gap-2">docker system</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/system/df/index.html" title="docker system df"><span class="flex items-center gap-2">docker system df</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/system/events/index.html" title="docker system events"><span class="flex items-center gap-2">docker system events</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/info/index.html" title="docker system info"><span class="flex items-center gap-2">docker system info</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/system/prune/index.html" title="docker system prune"><span class="flex items-center gap-2">docker system prune</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker trust
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/index.html" title="docker trust"><span class="flex items-center gap-2">docker trust</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/inspect/index.html" title="docker trust inspect"><span class="flex items-center gap-2">docker trust inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/key/index.html" title="docker trust key"><span class="flex items-center gap-2">docker trust key</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/key/generate/index.html" title="docker trust key generate"><span class="flex items-center gap-2">docker trust key generate</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/key/load/index.html" title="docker trust key load"><span class="flex items-center gap-2">docker trust key load</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/revoke/index.html" title="docker trust revoke"><span class="flex items-center gap-2">docker trust revoke</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/sign/index.html" title="docker trust sign"><span class="flex items-center gap-2">docker trust sign</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/signer/index.html" title="docker trust signer"><span class="flex items-center gap-2">docker trust signer</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/signer/add/index.html" title="docker trust signer add"><span class="flex items-center gap-2">docker trust signer add</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/trust/signer/remove/index.html" title="docker trust signer remove"><span class="flex items-center gap-2">docker trust signer remove</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/version/index.html" title="docker version"><span class="flex items-center gap-2">docker version</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">docker volume
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/create/index.html" title="docker volume create"><span class="flex items-center gap-2">docker volume create</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/inspect/index.html" title="docker volume inspect"><span class="flex items-center gap-2">docker volume inspect</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/ls/index.html" title="docker volume ls"><span class="flex items-center gap-2">docker volume ls</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/prune/index.html" title="docker volume prune"><span class="flex items-center gap-2">docker volume prune</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/rm/index.html" title="docker volume rm"><span class="flex items-center gap-2">docker volume rm</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../reference/cli/docker/volume/update/index.html" title="docker volume update"><span class="flex items-center gap-2">docker volume update</span></a></li></ul></li></ul></li><li class="pl-4 sidebar-hover rounded
bg-gray-light-200 dark:bg-gray-dark-200"><a aria-current=page class="py-2 w-full truncate block" href="index.html" title="Dockerfile reference"><span class="flex items-center gap-2">Dockerfile reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../commandline/dockerd/index.html" title="Daemon CLI (dockerd)"><span class="flex items-center gap-2">Daemon CLI (dockerd)</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">API reference
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Docker Engine API
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/index.html" title=Overview><span class="flex items-center gap-2">Overview</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/sdk/index.html" title=SDKs><span class="flex items-center gap-2">SDKs</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/sdk/examples/index.html" title="SDK examples"><span class="flex items-center gap-2">SDK examples</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/latest/index.html" title="v1.44 reference (latest)"><span class="flex items-center gap-2">v1.44 reference (latest)</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">API reference by version
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/version-history/index.html" title="Version history overview"><span class="flex items-center gap-2">Version history overview</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.42/index.html" title="v1.42 reference"><span class="flex items-center gap-2">v1.42 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.41/index.html" title="v1.41 reference"><span class="flex items-center gap-2">v1.41 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.40/index.html" title="v1.40 reference"><span class="flex items-center gap-2">v1.40 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.39/index.html" title="v1.39 reference"><span class="flex items-center gap-2">v1.39 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.38/index.html" title="v1.38 reference"><span class="flex items-center gap-2">v1.38 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.37/index.html" title="v1.37 reference"><span class="flex items-center gap-2">v1.37 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.36/index.html" title="v1.36 reference"><span class="flex items-center gap-2">v1.36 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.35/index.html" title="v1.35 reference"><span class="flex items-center gap-2">v1.35 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.34/index.html" title="v1.34 reference"><span class="flex items-center gap-2">v1.34 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.33/index.html" title="v1.33 reference"><span class="flex items-center gap-2">v1.33 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.32/index.html" title="v1.32 Reference"><span class="flex items-center gap-2">v1.32 Reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.31/index.html" title="v1.31 Reference"><span class="flex items-center gap-2">v1.31 Reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.30/index.html" title="v1.30 Reference"><span class="flex items-center gap-2">v1.30 Reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.29/index.html" title="v1.29 Reference"><span class="flex items-center gap-2">v1.29 Reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.28/index.html" title="v1.28 reference"><span class="flex items-center gap-2">v1.28 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.27/index.html" title="v1.27 reference"><span class="flex items-center gap-2">v1.27 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.26/index.html" title="v1.26 reference"><span class="flex items-center gap-2">v1.26 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.25/index.html" title="v1.25 reference"><span class="flex items-center gap-2">v1.25 reference</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../api/v1.24/index.html" title="v1.24 reference"><span class="flex items-center gap-2">v1.24 reference</span></a></li></ul></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Docker Hub API
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../docker-hub/api/latest/index.html" title="Docker Hub API"><span class="flex items-center gap-2">Docker Hub API</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../docker-hub/api/dvp/index.html" title="DVP Data API"><span class="flex items-center gap-2">DVP Data API</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../docker-hub/api/deprecated/index.html" title="Deprecated API"><span class="flex items-center gap-2">Deprecated API</span></a></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Docker Extension SDK API
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/DesktopUI/index.html" title=DesktopUI><span class="flex items-center gap-2">DesktopUI</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Dialog/index.html" title=Dialog><span class="flex items-center gap-2">Dialog</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Docker/index.html" title=Docker><span class="flex items-center gap-2">Docker</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/DockerCommand/index.html" title=DockerCommand><span class="flex items-center gap-2">DockerCommand</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/DockerDesktopClient/index.html" title=DockerDesktopClient><span class="flex items-center gap-2">DockerDesktopClient</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Exec/index.html" title=Exec><span class="flex items-center gap-2">Exec</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExecProcess/index.html" title=ExecProcess><span class="flex items-center gap-2">ExecProcess</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExecResult/index.html" title=ExecResult><span class="flex items-center gap-2">ExecResult</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExecStreamOptions/index.html" title=ExecStreamOptions><span class="flex items-center gap-2">ExecStreamOptions</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Extension/index.html" title=Extension><span class="flex items-center gap-2">Extension</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExtensionCli/index.html" title=ExtensionCli><span class="flex items-center gap-2">ExtensionCli</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExtensionHost/index.html" title=ExtensionHost><span class="flex items-center gap-2">ExtensionHost</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExtensionVM/index.html" title=ExtensionVM><span class="flex items-center gap-2">ExtensionVM</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Host/index.html" title=Host><span class="flex items-center gap-2">Host</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/HttpService/index.html" title=HttpService><span class="flex items-center gap-2">HttpService</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/NavigationIntents/index.html" title=NavigationIntents><span class="flex items-center gap-2">NavigationIntents</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/OpenDialogResult/index.html" title=OpenDialogResult><span class="flex items-center gap-2">OpenDialogResult</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/RawExecResult/index.html" title=RawExecResult><span class="flex items-center gap-2">RawExecResult</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/RequestConfig/index.html" title=RequestConfig><span class="flex items-center gap-2">RequestConfig</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/RequestConfigV0/index.html" title=RequestConfigV0><span class="flex items-center gap-2">RequestConfigV0</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/Toast/index.html" title=Toast><span class="flex items-center gap-2">Toast</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/ExecResultV0/index.html" title=ExecResultV0><span class="flex items-center gap-2">ExecResultV0</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../desktop/extensions-sdk/dev/api/reference/interfaces/BackendV0/index.html" title=BackendV0><span class="flex items-center gap-2">BackendV0</span></a></li></ul></li></ul></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Compose file reference
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Compose Specification
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file.html" title=Overview><span class="flex items-center gap-2">Overview</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/04-version-and-name/index.html" title="Version and name top-level element"><span class="flex items-center gap-2">Version and name top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/05-services/index.html" title="Services top-level element"><span class="flex items-center gap-2">Services top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/06-networks/index.html" title="Network top-level element"><span class="flex items-center gap-2">Network top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/07-volumes/index.html" title="Volumes top-level element"><span class="flex items-center gap-2">Volumes top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/08-configs/index.html" title="Configs top-level element"><span class="flex items-center gap-2">Configs top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/09-secrets/index.html" title="Secrets top-level element"><span class="flex items-center gap-2">Secrets top-level element</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/10-fragments/index.html" title=Fragments><span class="flex items-center gap-2">Fragments</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/11-extension/index.html" title=Extensions><span class="flex items-center gap-2">Extensions</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/12-interpolation/index.html" title=Interpolation><span class="flex items-center gap-2">Interpolation</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/13-merge/index.html" title=Merge><span class="flex items-center gap-2">Merge</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/14-include/index.html" title=Include><span class="flex items-center gap-2">Include</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/15-profiles/index.html" title=Profiles><span class="flex items-center gap-2">Profiles</span></a></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/build/index.html" title="Compose Build Specification"><span class="flex items-center gap-2">Compose Build Specification</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/deploy/index.html" title="Compose Deploy Specification"><span class="flex items-center gap-2">Compose Deploy Specification</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/develop/index.html" title="Compose Develop Specification"><span class="flex items-center gap-2">Compose Develop Specification</span></a></li><li><button class="rounded px-4 sidebar-hover w-full flex items-center justify-between">
<span class="py-2 truncate flex items-center gap-2">Legacy versions
</span><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-357q-6 0-11-2t-10-7L261-564q-9-9-9-21t9-21 21.5-9 21.5 9l176 176 176-176q9-9 21-9t21 9 9 21.5-9 21.5L501-366q-5 5-10 7t-11 2z"/></svg>
</span><span class="icon-svg hidden"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M480-543 304-367q-9 9-21.5 9.5T261-366t-9-21.5 9-21.5l198-198q5-5 10-7t11-2 11 2 10 7l197 197q9 9 9.5 21t-8.5 21-21.5 9-21.5-9L480-543z"/></svg></span></button><ul class="hidden ml-3 md:ml-[21px]"><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/compose-versioning/index.html" title="About versions and upgrading"><span class="flex items-center gap-2">About versions and upgrading</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/compose-file-v3/index.html" title="Version 3"><span class="flex items-center gap-2">Version 3</span></a></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../compose/compose-file/compose-file-v2/index.html" title="Version 2"><span class="flex items-center gap-2">Version 2</span></a></li></ul></li></ul></li><li class="pl-4 sidebar-hover rounded"><a class="py-2 w-full truncate block" href="../../../glossary/index.html" title=Glossary><span class="flex items-center gap-2">Glossary</span></a></li></ul></nav></div><div class="w-[840px] flex-initial overflow-clip p-6 pt-0 md:w-lvw"><nav id=breadcrumbs class="py-4 gap-4 flex items-center text-gray-light dark:text-gray-dark max-w-full min-w-0"><a href="../../../app/working-with-app/index.html" class="link truncate">Reference</a><span>/</span>
<span class=truncate>Dockerfile reference</span></nav><article class="DocSearch-content prose max-w-none dark:prose-invert"><h1 class=scroll-mt-20 id=dockerfile-reference><a class="text-black dark:text-white no-underline hover:underline" href="index.html#dockerfile-reference">Dockerfile reference</a></h1><p>Docker can build images automatically by reading the instructions from a
Dockerfile. A Dockerfile is a text document that contains all the commands a
user could call on the command line to assemble an image. This page describes
the commands you can use in a Dockerfile.</p><h2 class=scroll-mt-20 id=overview><a class="text-black dark:text-white no-underline hover:underline" href="index.html#overview">Overview</a></h2><p>The Dockerfile supports the following instructions:</p><table><thead><tr><th style=text-align:left>Instruction</th><th style=text-align:left>Description</th></tr></thead><tbody><tr><td style=text-align:left><a class=link href="index.html#add"><code>ADD</code></a></td><td style=text-align:left>Add local or remote files and directories.</td></tr><tr><td style=text-align:left><a class=link href="index.html#arg"><code>ARG</code></a></td><td style=text-align:left>Use build-time variables.</td></tr><tr><td style=text-align:left><a class=link href="index.html#cmd"><code>CMD</code></a></td><td style=text-align:left>Specify default commands.</td></tr><tr><td style=text-align:left><a class=link href="index.html#copy"><code>COPY</code></a></td><td style=text-align:left>Copy files and directories.</td></tr><tr><td style=text-align:left><a class=link href="index.html#entrypoint"><code>ENTRYPOINT</code></a></td><td style=text-align:left>Specify default executable.</td></tr><tr><td style=text-align:left><a class=link href="index.html#env"><code>ENV</code></a></td><td style=text-align:left>Set environment variables.</td></tr><tr><td style=text-align:left><a class=link href="index.html#expose"><code>EXPOSE</code></a></td><td style=text-align:left>Describe which ports your application is listening on.</td></tr><tr><td style=text-align:left><a class=link href="index.html#from"><code>FROM</code></a></td><td style=text-align:left>Create a new build stage from a base image.</td></tr><tr><td style=text-align:left><a class=link href="index.html#healthcheck"><code>HEALTHCHECK</code></a></td><td style=text-align:left>Check a container's health on startup.</td></tr><tr><td style=text-align:left><a class=link href="index.html#label"><code>LABEL</code></a></td><td style=text-align:left>Add metadata to an image.</td></tr><tr><td style=text-align:left><a class=link href="index.html#maintainer-deprecated"><code>MAINTAINER</code></a></td><td style=text-align:left>Specify the author of an image.</td></tr><tr><td style=text-align:left><a class=link href="index.html#onbuild"><code>ONBUILD</code></a></td><td style=text-align:left>Specify instructions for when the image is used in a build.</td></tr><tr><td style=text-align:left><a class=link href="index.html#run"><code>RUN</code></a></td><td style=text-align:left>Execute build commands.</td></tr><tr><td style=text-align:left><a class=link href="index.html#shell"><code>SHELL</code></a></td><td style=text-align:left>Set the default shell of an image.</td></tr><tr><td style=text-align:left><a class=link href="index.html#stopsignal"><code>STOPSIGNAL</code></a></td><td style=text-align:left>Specify the system call signal for exiting a container.</td></tr><tr><td style=text-align:left><a class=link href="index.html#user"><code>USER</code></a></td><td style=text-align:left>Set user and group ID.</td></tr><tr><td style=text-align:left><a class=link href="index.html#volume"><code>VOLUME</code></a></td><td style=text-align:left>Create volume mounts.</td></tr><tr><td style=text-align:left><a class=link href="index.html#workdir"><code>WORKDIR</code></a></td><td style=text-align:left>Change working directory.</td></tr></tbody></table><h2 class=scroll-mt-20 id=format><a class="text-black dark:text-white no-underline hover:underline" href="index.html#format">Format</a></h2><p>Here is the format of the Dockerfile:</p><div class="group relative"><button x-data="{ code: 'IyBDb21tZW50CklOU1RSVUNUSU9OIGFyZ3VtZW50cw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># Comment</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>INSTRUCTION arguments</span></span></code></pre></div></div></div><p>The instruction is not case-sensitive. However, convention is for them to
be UPPERCASE to distinguish them from arguments more easily.</p><p>Docker runs instructions in a Dockerfile in order. A Dockerfile <strong>must
begin with a <code>FROM</code> instruction</strong>. This may be after
<a class=link href="index.html#parser-directives">parser
directives</a>,
<a class=link href="index.html#format">comments</a>, and globally scoped
<a class=link href="index.html#arg">ARGs</a>. The <code>FROM</code> instruction specifies the
<a class=link href="../../../glossary/index.html#parent-image" target=_blank rel=noopener>parent
image<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> from which you are
building. <code>FROM</code> may only be preceded by one or more <code>ARG</code> instructions, which
declare arguments that are used in <code>FROM</code> lines in the Dockerfile.</p><p>BuildKit treats lines that begin with <code>#</code> as a comment, unless the line is
a valid
<a class=link href="index.html#parser-directives">parser directive</a>. A <code>#</code> marker anywhere
else in a line is treated as an argument. This allows statements like:</p><div class="group relative"><button x-data="{ code: 'IyBDb21tZW50ClJVTiBlY2hvICd3ZSBhcmUgcnVubmluZyBzb21lICMgb2YgY29vbCB0aGluZ3Mn', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># Comment</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s1>&#39;we are running some # of cool things&#39;</span></span></span></code></pre></div></div></div><p>Comment lines are removed before the Dockerfile instructions are executed.
The comment in the following example is removed before the shell executes
the <code>echo</code> command.</p><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gaGVsbG8gXAojIGNvbW1lbnQKd29ybGQ=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> hello <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span><span class=c1># comment</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>world</span></span></code></pre></div></div></div><p>The following examples is equivalent.</p><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gaGVsbG8gXAp3b3JsZA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> hello <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>world</span></span></code></pre></div></div></div><p>Comments don't support line continuation characters.</p><blockquote><p><strong>Note on whitespace</strong></p><p>For backward compatibility, leading whitespace before comments (<code>#</code>) and
instructions (such as <code>RUN</code>) are ignored, but discouraged. Leading whitespace
is not preserved in these cases, and the following examples are therefore
equivalent:</p><div class="group relative"><button x-data="{ code: 'ICAgICAgICAjIHRoaXMgaXMgYSBjb21tZW50LWxpbmUKICAgIFJVTiBlY2hvIGhlbGxvClJVTiBlY2hvIHdvcmxk', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl>        <span class=c1># this is a comment-line</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>    RUN <span class=nb>echo</span> hello<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> world</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'IyB0aGlzIGlzIGEgY29tbWVudC1saW5lClJVTiBlY2hvIGhlbGxvClJVTiBlY2hvIHdvcmxk', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># this is a comment-line</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> world</span></span></code></pre></div></div></div><p>Whitespace in instruction arguments, however, isn't ignored.
The following example prints <code>hello world</code>
with leading whitespace as specified:</p><div class="group relative"><button x-data="{ code: 'UlVOIGVjaG8gIlwKICAgICBoZWxsb1wKICAgICB3b3JsZCI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>&#34;\
</span></span></span><span class=line><span class=cl><span class=s2>     hello\
</span></span></span><span class=line><span class=cl><span class=s2>     world&#34;</span></span></span></code></pre></div></div></div></blockquote><h2 class=scroll-mt-20 id=parser-directives><a class="text-black dark:text-white no-underline hover:underline" href="index.html#parser-directives">Parser directives</a></h2><p>Parser directives are optional, and affect the way in which subsequent lines
in a Dockerfile are handled. Parser directives don't add layers to the build,
and don't show up as build steps. Parser directives are written as a
special type of comment in the form <code># directive=value</code>. A single directive
may only be used once.</p><p>Once a comment, empty line or builder instruction has been processed, BuildKit
no longer looks for parser directives. Instead it treats anything formatted
as a parser directive as a comment and doesn't attempt to validate if it might
be a parser directive. Therefore, all parser directives must be at the
top of a Dockerfile.</p><p>Parser directives aren't case-sensitive, but they're lowercase by convention.
It's also conventional to include a blank line following any parser directives.
Line continuation characters aren't supported in parser directives.</p><p>Due to these rules, the following examples are all invalid:</p><p>Invalid due to line continuation:</p><div class="group relative"><button x-data="{ code: 'IyBkaXJlYyBcCnRpdmU9dmFsdWU=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># direc \</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=nv>tive</span><span class=o>=</span>value</span></span></code></pre></div></div></div><p>Invalid due to appearing twice:</p><div class="group relative"><button x-data="{ code: 'IyBkaXJlY3RpdmU9dmFsdWUxCiMgZGlyZWN0aXZlPXZhbHVlMgoKRlJPTSBJbWFnZU5hbWU=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># directive=value1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value2</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ImageName</span></span></span></code></pre></div></div></div><p>Treated as a comment because it appears after a builder instruction:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBJbWFnZU5hbWUKIyBkaXJlY3RpdmU9dmFsdWU=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ImageName</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value</span></span></span></code></pre></div></div></div><p>Treated as a comment because it appears after a comment that isn't a parser
directive:</p><div class="group relative"><button x-data="{ code: 'IyBBYm91dCBteSBkb2NrZXJmaWxlCiMgZGlyZWN0aXZlPXZhbHVlCkZST00gSW1hZ2VOYW1l', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># About my dockerfile</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive=value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ImageName</span></span></span></code></pre></div></div></div><p>The following <code>unknowndirective</code> is treated as a comment because it isn't
recognized. The known <code>syntax</code> directive is treated as a comment because it
appears after a comment that isn't a parser directive.</p><div class="group relative"><button x-data="{ code: 'IyB1bmtub3duZGlyZWN0aXZlPXZhbHVlCiMgc3ludGF4PXZhbHVl', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># unknowndirective=value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># syntax=value</span></span></span></code></pre></div></div></div><p>Non line-breaking whitespace is permitted in a parser directive. Hence, the
following lines are all treated identically:</p><div class="group relative"><button x-data="{ code: 'I2RpcmVjdGl2ZT12YWx1ZQojIGRpcmVjdGl2ZSA9dmFsdWUKIwlkaXJlY3RpdmU9IHZhbHVlCiMgZGlyZWN0aXZlID0gdmFsdWUKIwkgIGRJckVjVGlWZT12YWx1ZQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c>#directive=value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive =value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c>#	directive= value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># directive = value</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c>#	  dIrEcTiVe=value</span></span></span></code></pre></div></div></div><p>The following parser directives are supported:</p><ul><li><code>syntax</code></li><li><code>escape</code></li></ul><h3 class=scroll-mt-20 id=syntax><a class="text-black dark:text-white no-underline hover:underline" href="index.html#syntax">syntax</a></h3><p><a name=external-implementation-features></a></p><p>Use the <code>syntax</code> parser directive to declare the Dockerfile syntax version to
use for the build. If unspecified, BuildKit uses a bundled version of the
Dockerfile frontend. Declaring a syntax version lets you automatically use the
latest Dockerfile version without having to upgrade BuildKit or Docker Engine,
or even use a custom Dockerfile implementation.</p><p>Most users will want to set this parser directive to <code>docker/dockerfile:1</code>,
which causes BuildKit to pull the latest stable version of the Dockerfile
syntax before the build.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span></span></span></code></pre></div></div></div><p>For more information about how the parser directive works, see
<a class=link href="../../../build/buildkit/dockerfile-frontend/index.html" target=_blank rel=noopener>Custom Dockerfile syntax<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p><h3 class=scroll-mt-20 id=escape><a class="text-black dark:text-white no-underline hover:underline" href="index.html#escape">escape</a></h3><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9XA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=\</span></span></span></code></pre></div></div></div><p>Or</p><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span></span></span></code></pre></div></div></div><p>The <code>escape</code> directive sets the character used to escape characters in a
Dockerfile. If not specified, the default escape character is <code>\</code>.</p><p>The escape character is used both to escape characters in a line, and to
escape a newline. This allows a Dockerfile instruction to
span multiple lines. Note that regardless of whether the <code>escape</code> parser
directive is included in a Dockerfile, escaping is not performed in
a <code>RUN</code> command, except at the end of a line.</p><p>Setting the escape character to <code>`</code> is especially useful on
<code>Windows</code>, where <code>\</code> is the directory path separator. <code>`</code> is consistent
with
<a class=link href=https://technet.microsoft.com/en-us/library/hh847755.aspx target=_blank rel=noopener>Windows PowerShell<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p><p>Consider the following example which would fail in a non-obvious way on
Windows. The second <code>\</code> at the end of the second line would be interpreted as an
escape for the newline, instead of a target of the escape from the first <code>\</code>.
Similarly, the <code>\</code> at the end of the third line would, assuming it was actually
handled as an instruction, cause it be treated as a line continuation. The result
of this Dockerfile is that second and third lines are considered a single
instruction:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpDT1BZIHRlc3RmaWxlLnR4dCBjOlxcClJVTiBkaXIgYzpc', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> testfile.txt c:<span class=se>\\</span>
</span></span><span class=line><span class=cl>RUN dir c:<span class=err>\</span></span></span></code></pre></div></div></div><p>Results in:</p><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgY21kIC4KClNlbmRpbmcgYnVpbGQgY29udGV4dCB0byBEb2NrZXIgZGFlbW9uIDMuMDcyIGtCClN0ZXAgMS8yIDogRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgogLS0tPiAyMjczOGZmNDljNmQKU3RlcCAyLzIgOiBDT1BZIHRlc3RmaWxlLnR4dCBjOlxSVU4gZGlyIGM6CkdldEZpbGVBdHRyaWJ1dGVzRXggYzpSVU46IFRoZSBzeXN0ZW0gY2Fubm90IGZpbmQgdGhlIGZpbGUgc3BlY2lmaWVkLgpQUyBFOlxteXByb2plY3Q+', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject&gt; docker build -t cmd .
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 3.072 kB
</span></span></span><span class=line><span class=cl><span class=go>Step 1/2 : FROM microsoft/nanoserver
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 22738ff49c6d
</span></span></span><span class=line><span class=cl><span class=go>Step 2/2 : COPY testfile.txt c:\RUN dir c:
</span></span></span><span class=line><span class=cl><span class=go>GetFileAttributesEx c:RUN: The system cannot find the file specified.
</span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject&gt;
</span></span></span></code></pre></div></div></div><p>One solution to the above would be to use <code>/</code> as the target of both the <code>COPY</code>
instruction, and <code>dir</code>. However, this syntax is, at best, confusing as it is not
natural for paths on Windows, and at worst, error prone as not all commands on
Windows support <code>/</code> as the path separator.</p><p>By adding the <code>escape</code> parser directive, the following Dockerfile succeeds as
expected with the use of natural platform semantics for file paths on Windows:</p><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YAoKRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpDT1BZIHRlc3RmaWxlLnR4dCBjOlwKUlVOIGRpciBjOlw=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> testfile.txt c:<span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>RUN dir c:<span class=err>\</span></span></span></code></pre></div></div></div><p>Results in:</p><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgc3VjY2VlZHMgLS1uby1jYWNoZT10cnVlIC4KClNlbmRpbmcgYnVpbGQgY29udGV4dCB0byBEb2NrZXIgZGFlbW9uIDMuMDcyIGtCClN0ZXAgMS8zIDogRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgogLS0tPiAyMjczOGZmNDljNmQKU3RlcCAyLzMgOiBDT1BZIHRlc3RmaWxlLnR4dCBjOlwKIC0tLT4gOTY2NTVkZTMzOGRlClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgNGRiOWFjYmIxNjgyClN0ZXAgMy8zIDogUlVOIGRpciBjOlwKIC0tLT4gUnVubmluZyBpbiBhMmMxNTdmODQyZjUKIFZvbHVtZSBpbiBkcml2ZSBDIGhhcyBubyBsYWJlbC4KIFZvbHVtZSBTZXJpYWwgTnVtYmVyIGlzIDdFNkQtRTBGNwoKIERpcmVjdG9yeSBvZiBjOlwKCjEwLzA1LzIwMTYgIDA1OjA0IFBNICAgICAgICAgICAgIDEsODk0IExpY2Vuc2UudHh0CjEwLzA1LzIwMTYgIDAyOjIyIFBNICAgIDxESVI+ICAgICAgICAgIFByb2dyYW0gRmlsZXMKMTAvMDUvMjAxNiAgMDI6MTQgUE0gICAgPERJUj4gICAgICAgICAgUHJvZ3JhbSBGaWxlcyAoeDg2KQoxMC8yOC8yMDE2ICAxMToxOCBBTSAgICAgICAgICAgICAgICA2MiB0ZXN0ZmlsZS50eHQKMTAvMjgvMjAxNiAgMTE6MjAgQU0gICAgPERJUj4gICAgICAgICAgVXNlcnMKMTAvMjgvMjAxNiAgMTE6MjAgQU0gICAgPERJUj4gICAgICAgICAgV2luZG93cwogICAgICAgICAgIDIgRmlsZShzKSAgICAgICAgICAxLDk1NiBieXRlcwogICAgICAgICAgIDQgRGlyKHMpICAyMSwyNTksMDk2LDA2NCBieXRlcyBmcmVlCiAtLS0+IDAxYzdmM2JlZjA0ZgpSZW1vdmluZyBpbnRlcm1lZGlhdGUgY29udGFpbmVyIGEyYzE1N2Y4NDJmNQpTdWNjZXNzZnVsbHkgYnVpbHQgMDFjN2YzYmVmMDRmClBTIEU6XG15cHJvamVjdD4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject&gt; docker build -t succeeds --no-cache=true .
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 3.072 kB
</span></span></span><span class=line><span class=cl><span class=go>Step 1/3 : FROM microsoft/nanoserver
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 22738ff49c6d
</span></span></span><span class=line><span class=cl><span class=go>Step 2/3 : COPY testfile.txt c:\
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 96655de338de
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container 4db9acbb1682
</span></span></span><span class=line><span class=cl><span class=go>Step 3/3 : RUN dir c:\
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; Running in a2c157f842f5
</span></span></span><span class=line><span class=cl><span class=go> Volume in drive C has no label.
</span></span></span><span class=line><span class=cl><span class=go> Volume Serial Number is 7E6D-E0F7
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go> Directory of c:\
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>10/05/2016  05:04 PM             1,894 License.txt
</span></span></span><span class=line><span class=cl><span class=go>10/05/2016  02:22 PM    &lt;DIR&gt;          Program Files
</span></span></span><span class=line><span class=cl><span class=go>10/05/2016  02:14 PM    &lt;DIR&gt;          Program Files (x86)
</span></span></span><span class=line><span class=cl><span class=go>10/28/2016  11:18 AM                62 testfile.txt
</span></span></span><span class=line><span class=cl><span class=go>10/28/2016  11:20 AM    &lt;DIR&gt;          Users
</span></span></span><span class=line><span class=cl><span class=go>10/28/2016  11:20 AM    &lt;DIR&gt;          Windows
</span></span></span><span class=line><span class=cl><span class=go>           2 File(s)          1,956 bytes
</span></span></span><span class=line><span class=cl><span class=go>           4 Dir(s)  21,259,096,064 bytes free
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 01c7f3bef04f
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container a2c157f842f5
</span></span></span><span class=line><span class=cl><span class=go>Successfully built 01c7f3bef04f
</span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject&gt;
</span></span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=environment-replacement><a class="text-black dark:text-white no-underline hover:underline" href="index.html#environment-replacement">Environment replacement</a></h2><p>Environment variables (declared with
<a class=link href="index.html#env">the <code>ENV</code> statement</a>) can also be
used in certain instructions as variables to be interpreted by the
Dockerfile. Escapes are also handled for including variable-like syntax
into a statement literally.</p><p>Environment variables are notated in the Dockerfile either with
<code>$variable_name</code> or <code>${variable_name}</code>. They are treated equivalently and the
brace syntax is typically used to address issues with variable names with no
whitespace, like <code>${foo}_bar</code>.</p><p>The <code>${variable_name}</code> syntax also supports a few of the standard <code>bash</code>
modifiers as specified below:</p><ul><li><code>${variable:-word}</code> indicates that if <code>variable</code> is set then the result
will be that value. If <code>variable</code> is not set then <code>word</code> will be the result.</li><li><code>${variable:+word}</code> indicates that if <code>variable</code> is set then <code>word</code> will be
the result, otherwise the result is the empty string.</li></ul><p>The following variable replacements are supported in a pre-release version of
Dockerfile syntax, when using the <code># syntax=docker/dockerfile-upstream:master</code> syntax
directive in your Dockerfile:</p><ul><li><p><code>${variable#pattern}</code> removes the shortest match of <code>pattern</code> from <code>variable</code>,
seeking from the start of the string.</p><div class="group relative"><button x-data="{ code: 'c3RyPWZvb2JhcmJheiBlY2hvICR7c3RyI2YqYn0gICAgICMgYXJiYXo=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>str</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>str</span><span class=p>#f*b</span><span class=si>}</span>     <span class=c1># arbaz</span></span></span></code></pre></div></div></div></li><li><p><code>${variable##pattern}</code> removes the longest match of <code>pattern</code> from <code>variable</code>,
seeking from the start of the string.</p><div class="group relative"><button x-data="{ code: 'c3RyPWZvb2JhcmJheiBlY2hvICR7c3RyIyNmKmJ9ICAgICMgYXo=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>str</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>str</span><span class=p>##f*b</span><span class=si>}</span>    <span class=c1># az</span></span></span></code></pre></div></div></div></li><li><p><code>${variable%pattern}</code> removes the shortest match of <code>pattern</code> from <code>variable</code>,
seeking backwards from the end of the string.</p><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nJWIqfSAgICAjIGZvb2Jhcg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>%b*</span><span class=si>}</span>    <span class=c1># foobar</span></span></span></code></pre></div></div></div></li><li><p><code>${variable%%pattern}</code> removes the longest match of <code>pattern</code> from <code>variable</code>,
seeking backwards from the end of the string.</p><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nJSViKn0gICAjIGZvbw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>%%b*</span><span class=si>}</span>   <span class=c1># foo</span></span></span></code></pre></div></div></div></li><li><p><code>${variable/pattern/replacement}</code> replace the first occurrence of <code>pattern</code>
in <code>variable</code> with <code>replacement</code></p><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nL2JhL2ZvfSAgIyBmb29mb3JiYXo=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>/ba/fo</span><span class=si>}</span>  <span class=c1># fooforbaz</span></span></span></code></pre></div></div></div></li><li><p><code>${variable//pattern/replacement}</code> replaces all occurrences of <code>pattern</code>
in <code>variable</code> with <code>replacement</code></p><div class="group relative"><button x-data="{ code: 'c3RyaW5nPWZvb2JhcmJheiBlY2hvICR7c3RyaW5nLy9iYS9mb30gICMgZm9vZm9yZm96', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=nv>string</span><span class=o>=</span>foobarbaz <span class=nb>echo</span> <span class=si>${</span><span class=nv>string</span><span class=p>//ba/fo</span><span class=si>}</span>  <span class=c1># fooforfoz</span></span></span></code></pre></div></div></div></li></ul><p>In all cases, <code>word</code> can be any string, including additional environment
variables.</p><p><code>pattern</code> is a glob pattern where <code>?</code> matches any single character
and <code>*</code> any number of characters (including zero). To match literal <code>?</code> and <code>*</code>,
use a backslash escape: <code>\?</code> and <code>\*</code>.</p><p>You can escape whole variable names by adding a <code>\</code> before the variable: <code>\$foo</code> or <code>\${foo}</code>,
for example, will translate to <code>$foo</code> and <code>${foo}</code> literals respectively.</p><p>Example (parsed representation is displayed after the <code>#</code>):</p><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkVOViBGT089L2JhcgpXT1JLRElSICR7Rk9PfSAgICMgV09SS0RJUiAvYmFyCkFERCAuICRGT08gICAgICAgIyBBREQgLiAvYmFyCkNPUFkgXCRGT08gL3F1dXggIyBDT1BZICRGT08gL3F1dXg=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>FOO</span><span class=o>=</span>/bar<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> ${FOO}   # WORKDIR /bar</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> . <span class=nv>$FOO</span>       <span class=c1># ADD . /bar</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> <span class=se>\$</span>FOO /quux <span class=c1># COPY $FOO /quux</span></span></span></code></pre></div></div></div><p>Environment variables are supported by the following list of instructions in
the Dockerfile:</p><ul><li><code>ADD</code></li><li><code>COPY</code></li><li><code>ENV</code></li><li><code>EXPOSE</code></li><li><code>FROM</code></li><li><code>LABEL</code></li><li><code>STOPSIGNAL</code></li><li><code>USER</code></li><li><code>VOLUME</code></li><li><code>WORKDIR</code></li><li><code>ONBUILD</code> (when combined with one of the supported instructions above)</li></ul><p>You can also use environment variables with <code>RUN</code>, <code>CMD</code>, and <code>ENTRYPOINT</code>
instructions, but in those cases the variable substitution is handled by the
command shell, not the builder. Note that instructions using the exec form
don't invoke a command shell automatically. See
<a class=link href="index.html#variable-substitution">Variable
substitution</a>.</p><p>Environment variable substitution use the same value for each variable
throughout the entire instruction. Changing the value of a variable only takes
effect in subsequent instructions. Consider the following example:</p><div class="group relative"><button x-data="{ code: 'RU5WIGFiYz1oZWxsbwpFTlYgYWJjPWJ5ZSBkZWY9JGFiYwpFTlYgZ2hpPSRhYmM=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>abc</span><span class=o>=</span>hello
</span></span><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>abc</span><span class=o>=</span>bye <span class=nv>def</span><span class=o>=</span><span class=nv>$abc</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>ghi</span><span class=o>=</span><span class=nv>$abc</span></span></span></code></pre></div></div></div><ul><li>The value of <code>def</code> becomes <code>hello</code></li><li>The value of <code>ghi</code> becomes <code>bye</code></li></ul><h2 class=scroll-mt-20 id=dockerignore-file><a class="text-black dark:text-white no-underline hover:underline" href="index.html#dockerignore-file">.dockerignore file</a></h2><p>You can use <code>.dockerignore</code> file to exclude files and directories from the
build context. For more information, see
<a class=link href="../../../build/building/context/index.html#dockerignore-files" target=_blank rel=noopener>.dockerignore file<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p><h2 class=scroll-mt-20 id=shell-and-exec-form><a class="text-black dark:text-white no-underline hover:underline" href="index.html#shell-and-exec-form">Shell and exec form</a></h2><p>The <code>RUN</code>, <code>CMD</code>, and <code>ENTRYPOINT</code> instructions all have two possible forms:</p><ul><li><code>INSTRUCTION ["executable","param1","param2"]</code> (exec form)</li><li><code>INSTRUCTION command param1 param2</code> (shell form)</li></ul><p>The exec form makes it possible to avoid shell string munging, and to invoke
commands using a specific command shell, or any other executable. It uses a
JSON array syntax, where each element in the array is a command, flag, or
argument.</p><p>The shell form is more relaxed, and emphasizes ease of use, flexibility, and
readability. The shell form automatically uses a command shell, whereas the
exec form does not.</p><h3 class=scroll-mt-20 id=exec-form><a class="text-black dark:text-white no-underline hover:underline" href="index.html#exec-form">Exec form</a></h3><p>The exec form is parsed as a JSON array, which means that
you must use double-quotes (") around words, not single-quotes (').</p><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBbIi9iaW4vYmFzaCIsICItYyIsICJlY2hvIiwgImhlbGxvIl0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>&#34;/bin/bash&#34;</span><span class=p>,</span> <span class=s2>&#34;-c&#34;</span><span class=p>,</span> <span class=s2>&#34;echo&#34;</span><span class=p>,</span> <span class=s2>&#34;hello&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div><p>The exec form is best used to specify an <code>ENTRYPOINT</code> instruction, combined
with <code>CMD</code> for setting default arguments that can be overridden at runtime. For
more information, see
<a class=link href="index.html#entrypoint">ENTRYPOINT</a>.</p><h4 class=scroll-mt-20 id=variable-substitution><a class="text-black dark:text-white no-underline hover:underline" href="index.html#variable-substitution">Variable substitution</a></h4><p>Using the exec form doesn't automatically invoke a command shell. This means
that normal shell processing, such as variable substitution, doesn't happen.
For example, <code>RUN [ "echo", "$HOME" ]</code> won't handle variable substitution for
<code>$HOME</code>.</p><p>If you want shell processing then either use the shell form or execute a shell
directly with the exec form, for example: <code>RUN [ "sh", "-c", "echo $HOME" ]</code>.
When using the exec form and executing a shell directly, as in the case for the
shell form, it's the shell that's doing the environment variable substitution,
not the builder.</p><h4 class=scroll-mt-20 id=backslashes><a class="text-black dark:text-white no-underline hover:underline" href="index.html#backslashes">Backslashes</a></h4><p>In exec form, you must escape backslashes. This is particularly relevant on
Windows where the backslash is the path separator. The following line would
otherwise be treated as shell form due to not being valid JSON, and fail in an
unexpected way:</p><div class="group relative"><button x-data="{ code: 'UlVOIFsiYzpcd2luZG93c1xzeXN0ZW0zMlx0YXNrbGlzdC5leGUiXQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>&#34;c:\windows\system32\tasklist.exe&#34;</span><span class=o>]</span></span></span></code></pre></div></div></div><p>The correct syntax for this example is:</p><div class="group relative"><button x-data="{ code: 'UlVOIFsiYzpcXHdpbmRvd3NcXHN5c3RlbTMyXFx0YXNrbGlzdC5leGUiXQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>&#34;c:\\windows\\system32\\tasklist.exe&#34;</span><span class=o>]</span></span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=shell-form><a class="text-black dark:text-white no-underline hover:underline" href="index.html#shell-form">Shell form</a></h3><p>Unlike the exec form, instructions using the shell form always use a command
shell. The shell form doesn't use the JSON array format, instead it's a regular
string. The shell form string lets you escape newlines using the
<a class=link href="index.html#escape">escape
character</a> (backslash by default) to continue a single instruction
onto the next line. This makes it easier to use with longer commands, because
it lets you split them up into multiple lines. For example, consider these two
lines:</p><div class="group relative"><button x-data="{ code: 'UlVOIHNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIFwKZWNobyAkSE9NRQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&amp;&amp;</span> <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span><span class=nb>echo</span> <span class=nv>$HOME</span></span></span></code></pre></div></div></div><p>They're equivalent to the following line:</p><div class="group relative"><button x-data="{ code: 'UlVOIHNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIGVjaG8gJEhPTUU=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&amp;&amp;</span> <span class=nb>echo</span> <span class=nv>$HOME</span></span></span></code></pre></div></div></div><p>You can also use heredocs with the shell form to break up a command:</p><div class="group relative"><button x-data="{ code: 'UlVOIDw8RU9GCnNvdXJjZSAkSE9NRS8uYmFzaHJjICYmIFwKZWNobyAkSE9NRQpFT0Y=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> &lt;&lt;EOF<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=nb>source</span> <span class=nv>$HOME</span>/.bashrc <span class=o>&amp;&amp;</span> <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span><span class=nb>echo</span> <span class=nv>$HOME</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div><p>For more information about heredocs, see
<a class=link href="index.html#here-documents">Here-documents</a>.</p><h3 class=scroll-mt-20 id=use-a-different-shell><a class="text-black dark:text-white no-underline hover:underline" href="index.html#use-a-different-shell">Use a different shell</a></h3><p>You can change the default shell using the <code>SHELL</code> command. For example:</p><div class="group relative"><button x-data="{ code: 'U0hFTEwgWyIvYmluL2Jhc2giLCAiLWMiXQpSVU4gZWNobyBoZWxsbw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>SHELL</span> <span class=p>[</span><span class=s2>&#34;/bin/bash&#34;</span><span class=p>,</span> <span class=s2>&#34;-c&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div><p>For more information, see
<a class=link href="index.html#shell">SHELL</a>.</p><h2 class=scroll-mt-20 id=from><a class="text-black dark:text-white no-underline hover:underline" href="index.html#from">FROM</a></h2><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+IFtBUyA8bmFtZT5d', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=&lt;platform&gt;] &lt;image&gt; [AS &lt;name&gt;]</span></span></span></code></pre></div></div></div><p>Or</p><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+Wzo8dGFnPl0gW0FTIDxuYW1lPl0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=&lt;platform&gt;] &lt;image&gt;[:&lt;tag&gt;] [AS &lt;name&gt;]</span></span></span></code></pre></div></div></div><p>Or</p><div class="group relative"><button x-data="{ code: 'RlJPTSBbLS1wbGF0Zm9ybT08cGxhdGZvcm0+XSA8aW1hZ2U+W0A8ZGlnZXN0Pl0gW0FTIDxuYW1lPl0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> [--platform=&lt;platform&gt;] &lt;image&gt;[@&lt;digest&gt;] [AS &lt;name&gt;]</span></span></span></code></pre></div></div></div><p>The <code>FROM</code> instruction initializes a new build stage and sets the
<a class=link href="../../../glossary/index.html#base-image" target=_blank rel=noopener>base image<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> for subsequent
instructions. As such, a valid Dockerfile must start with a <code>FROM</code> instruction.
The image can be any valid image.</p><ul><li><code>ARG</code> is the only instruction that may precede <code>FROM</code> in the Dockerfile.
See
<a class=link href="index.html#understand-how-arg-and-from-interact">Understand how ARG and FROM interact</a>.</li><li><code>FROM</code> can appear multiple times within a single Dockerfile to
create multiple images or use one build stage as a dependency for another.
Simply make a note of the last image ID output by the commit before each new
<code>FROM</code> instruction. Each <code>FROM</code> instruction clears any state created by previous
instructions.</li><li>Optionally a name can be given to a new build stage by adding <code>AS name</code> to the
<code>FROM</code> instruction. The name can be used in subsequent <code>FROM</code> and
<code>COPY --from=&lt;name></code> instructions to refer to the image built in this stage.</li><li>The <code>tag</code> or <code>digest</code> values are optional. If you omit either of them, the
builder assumes a <code>latest</code> tag by default. The builder returns an error if it
can't find the <code>tag</code> value.</li></ul><p>The optional <code>--platform</code> flag can be used to specify the platform of the image
in case <code>FROM</code> references a multi-platform image. For example, <code>linux/amd64</code>,
<code>linux/arm64</code>, or <code>windows/amd64</code>. By default, the target platform of the build
request is used. Global build arguments can be used in the value of this flag,
for example
<a class=link href="index.html#automatic-platform-args-in-the-global-scope">automatic platform ARGs</a>
allow you to force a stage to native build platform (<code>--platform=$BUILDPLATFORM</code>),
and use it to cross-compile to the target platform inside the stage.</p><h3 class=scroll-mt-20 id=understand-how-arg-and-from-interact><a class="text-black dark:text-white no-underline hover:underline" href="index.html#understand-how-arg-and-from-interact">Understand how ARG and FROM interact</a></h3><p><code>FROM</code> instructions support variables that are declared by any <code>ARG</code>
instructions that occur before the first <code>FROM</code>.</p><div class="group relative"><button x-data="{ code: 'QVJHICBDT0RFX1ZFUlNJT049bGF0ZXN0CkZST00gYmFzZToke0NPREVfVkVSU0lPTn0KQ01EICAvY29kZS9ydW4tYXBwCgpGUk9NIGV4dHJhczoke0NPREVfVkVSU0lPTn0KQ01EICAvY29kZS9ydW4tZXh0cmFz', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span>  <span class=nv>CODE_VERSION</span><span class=o>=</span>latest
</span></span><span class=line><span class=cl><span class=k>FROM</span><span class=s> base:${CODE_VERSION}</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span>  /code/run-app<span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> extras:${CODE_VERSION}</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span>  /code/run-extras</span></span></code></pre></div></div></div><p>An <code>ARG</code> declared before a <code>FROM</code> is outside of a build stage, so it
can't be used in any instruction after a <code>FROM</code>. To use the default value of
an <code>ARG</code> declared before the first <code>FROM</code> use an <code>ARG</code> instruction without
a value inside of a build stage:</p><div class="group relative"><button x-data="{ code: 'QVJHIFZFUlNJT049bGF0ZXN0CkZST00gYnVzeWJveDokVkVSU0lPTgpBUkcgVkVSU0lPTgpSVU4gZWNobyAkVkVSU0lPTiA+IGltYWdlX3ZlcnNpb24=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>VERSION</span><span class=o>=</span>latest
</span></span><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox:$VERSION</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> VERSION<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$VERSION</span> &gt; image_version</span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=run><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run">RUN</a></h2><p>The <code>RUN</code> instruction will execute any commands to create a new layer on top of
the current image. The added layer is used in the next step in the Dockerfile.</p><div class="group relative"><button x-data="{ code: 'UlVOIGFwdC1nZXQgdXBkYXRlClJVTiBhcHQtZ2V0IGluc3RhbGwgLXkgY3VybA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> apt-get update<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apt-get install -y curl</span></span></code></pre></div></div></div><p>You can specify <code>RUN</code> instructions using
<a class=link href="index.html#shell-and-exec-form">shell or exec forms</a>:</p><ul><li><code>RUN ["executable","param1","param2"]</code> (exec form)</li><li><code>RUN command param1 param2</code> (shell form)</li></ul><p>The shell form is most commonly used, and lets you more easily break up longer
instructions into multiple lines, either using newline
<a class=link href="index.html#escape">escapes</a>, or
with
<a class=link href="index.html#here-documents">heredocs</a>:</p><div class="group relative"><button x-data="{ code: 'UlVOIDw8RU9GCmFwdC1nZXQgdXBkYXRlCmFwdC1nZXQgaW5zdGFsbCAteSBjdXJsCkVPRg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> &lt;&lt;EOF<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>apt-get update<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>apt-get install -y curl<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=cache-invalidation-for-run-instructions><a class="text-black dark:text-white no-underline hover:underline" href="index.html#cache-invalidation-for-run-instructions">Cache invalidation for RUN instructions</a></h3><p>The cache for <code>RUN</code> instructions isn't invalidated automatically during
the next build. The cache for an instruction like
<code>RUN apt-get dist-upgrade -y</code> will be reused during the next build. The
cache for <code>RUN</code> instructions can be invalidated by using the <code>--no-cache</code>
flag, for example <code>docker build --no-cache</code>.</p><p>See the
<a class=link href="../../userguide/eng-image/dockerfile_best-practices/index.html" target=_blank rel=noopener>Dockerfile Best Practices
guide<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> for more information.</p><p>The cache for <code>RUN</code> instructions can be invalidated by
<a class=link href="index.html#add"><code>ADD</code></a> and
<a class=link href="index.html#copy"><code>COPY</code></a> instructions.</p><h2 class=scroll-mt-20 id=run---mount><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mount">RUN --mount</a></h2><blockquote><p><strong>Note</strong></p><p>Added in
<a class=link href="index.html#syntax"><code>docker/dockerfile:1.2</code></a></p></blockquote><p><code>RUN --mount</code> allows you to create filesystem mounts that the build can access.
This can be used to:</p><ul><li>Create bind mount to the host filesystem or other build stages</li><li>Access build secrets or ssh-agent sockets</li><li>Use a persistent package management cache to speed up your build</li></ul><p>Syntax: <code>--mount=[type=&lt;TYPE>][,option=&lt;value>[,option=&lt;value>]...]</code></p><h3 class=scroll-mt-20 id=mount-types><a class="text-black dark:text-white no-underline hover:underline" href="index.html#mount-types">Mount types</a></h3><table><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><a class=link href="index.html#run---mounttypebind"><code>bind</code></a> (default)</td><td>Bind-mount context directories (read-only).</td></tr><tr><td><a class=link href="index.html#run---mounttypecache"><code>cache</code></a></td><td>Mount a temporary directory to cache directories for compilers and package managers.</td></tr><tr><td><a class=link href="index.html#run---mounttypesecret"><code>secret</code></a></td><td>Allow the build container to access secure files such as private keys without baking them into the image.</td></tr><tr><td><a class=link href="index.html#run---mounttypessh"><code>ssh</code></a></td><td>Allow the build container to access SSH keys via SSH agents, with support for passphrases.</td></tr></tbody></table><h3 class=scroll-mt-20 id=run---mounttypebind><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mounttypebind">RUN --mount=type=bind</a></h3><p>This mount type allows binding files or directories to the build container. A
bind mount is read-only by default.</p><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>target</code><sup id=fnref:1><a href="index.html#fn:1" class=footnote-ref role=doc-noteref>1</a></sup></td><td>Mount path.</td></tr><tr><td><code>source</code></td><td>Source path in the <code>from</code>. Defaults to the root of the <code>from</code>.</td></tr><tr><td><code>from</code></td><td>Build stage or image name for the root of the source. Defaults to the build context.</td></tr><tr><td><code>rw</code>,<code>readwrite</code></td><td>Allow writes on the mount. Written data will be discarded.</td></tr></tbody></table><h3 class=scroll-mt-20 id=run---mounttypecache><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mounttypecache">RUN --mount=type=cache</a></h3><p>This mount type allows the build container to cache directories for compilers
and package managers.</p><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>Optional ID to identify separate/different caches. Defaults to value of <code>target</code>.</td></tr><tr><td><code>target</code><sup id=fnref1:1><a href="index.html#fn:1" class=footnote-ref role=doc-noteref>1</a></sup></td><td>Mount path.</td></tr><tr><td><code>ro</code>,<code>readonly</code></td><td>Read-only if set.</td></tr><tr><td><code>sharing</code></td><td>One of <code>shared</code>, <code>private</code>, or <code>locked</code>. Defaults to <code>shared</code>. A <code>shared</code> cache mount can be used concurrently by multiple writers. <code>private</code> creates a new mount if there are multiple writers. <code>locked</code> pauses the second writer until the first one releases the mount.</td></tr><tr><td><code>from</code></td><td>Build stage to use as a base of the cache mount. Defaults to empty directory.</td></tr><tr><td><code>source</code></td><td>Subpath in the <code>from</code> to mount. Defaults to the root of the <code>from</code>.</td></tr><tr><td><code>mode</code></td><td>File mode for new cache directory in octal. Default <code>0755</code>.</td></tr><tr><td><code>uid</code></td><td>User ID for new cache directory. Default <code>0</code>.</td></tr><tr><td><code>gid</code></td><td>Group ID for new cache directory. Default <code>0</code>.</td></tr></tbody></table><p>Contents of the cache directories persists between builder invocations without
invalidating the instruction cache. Cache mounts should only be used for better
performance. Your build should work with any contents of the cache directory as
another build may overwrite the files or GC may clean it if more storage space
is needed.</p><h4 class=scroll-mt-20 id=example-cache-go-packages><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-cache-go-packages">Example: cache Go packages</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGdvbGFuZwpSVU4gLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vcm9vdC8uY2FjaGUvZ28tYnVpbGQgXAogIGdvIGJ1aWxkIC4uLg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> golang</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/root/.cache/go-build <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  go build ...</span></span></code></pre></div></div></div><h4 class=scroll-mt-20 id=example-cache-apt-packages><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-cache-apt-packages">Example: cache apt packages</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHVidW50dQpSVU4gcm0gLWYgL2V0Yy9hcHQvYXB0LmNvbmYuZC9kb2NrZXItY2xlYW47IGVjaG8gJ0JpbmFyeTo6YXB0OjpBUFQ6OktlZXAtRG93bmxvYWRlZC1QYWNrYWdlcyAidHJ1ZSI7JyA+IC9ldGMvYXB0L2FwdC5jb25mLmQva2VlcC1jYWNoZQpSVU4gLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vdmFyL2NhY2hlL2FwdCxzaGFyaW5nPWxvY2tlZCBcCiAgLS1tb3VudD10eXBlPWNhY2hlLHRhcmdldD0vdmFyL2xpYi9hcHQsc2hhcmluZz1sb2NrZWQgXAogIGFwdCB1cGRhdGUgJiYgYXB0LWdldCAtLW5vLWluc3RhbGwtcmVjb21tZW5kcyBpbnN0YWxsIC15IGdjYw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> rm -f /etc/apt/apt.conf.d/docker-clean<span class=p>;</span> <span class=nb>echo</span> <span class=s1>&#39;Binary::apt::APT::Keep-Downloaded-Packages &#34;true&#34;;&#39;</span> &gt; /etc/apt/apt.conf.d/keep-cache<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/var/cache/apt,sharing<span class=o>=</span>locked <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>cache,target<span class=o>=</span>/var/lib/apt,sharing<span class=o>=</span>locked <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  apt update <span class=o>&amp;&amp;</span> apt-get --no-install-recommends install -y gcc</span></span></code></pre></div></div></div><p>Apt needs exclusive access to its data, so the caches use the option
<code>sharing=locked</code>, which will make sure multiple parallel builds using
the same cache mount will wait for each other and not access the same
cache files at the same time. You could also use <code>sharing=private</code> if
you prefer to have each build create another cache directory in this
case.</p><h3 class=scroll-mt-20 id=run---mounttypetmpfs><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mounttypetmpfs">RUN --mount=type=tmpfs</a></h3><p>This mount type allows mounting <code>tmpfs</code> in the build container.</p><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>target</code><sup id=fnref2:1><a href="index.html#fn:1" class=footnote-ref role=doc-noteref>1</a></sup></td><td>Mount path.</td></tr><tr><td><code>size</code></td><td>Specify an upper limit on the size of the filesystem.</td></tr></tbody></table><h3 class=scroll-mt-20 id=run---mounttypesecret><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mounttypesecret">RUN --mount=type=secret</a></h3><p>This mount type allows the build container to access secure files such as
private keys without baking them into the image.</p><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>ID of the secret. Defaults to basename of the target path.</td></tr><tr><td><code>target</code></td><td>Mount path. Defaults to <code>/run/secrets/</code> + <code>id</code>.</td></tr><tr><td><code>required</code></td><td>If set to <code>true</code>, the instruction errors out when the secret is unavailable. Defaults to <code>false</code>.</td></tr><tr><td><code>mode</code></td><td>File mode for secret file in octal. Default <code>0400</code>.</td></tr><tr><td><code>uid</code></td><td>User ID for secret file. Default <code>0</code>.</td></tr><tr><td><code>gid</code></td><td>Group ID for secret file. Default <code>0</code>.</td></tr></tbody></table><h4 class=scroll-mt-20 id=example-access-to-s3><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-access-to-s3">Example: access to S3</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozClJVTiBwaXAgaW5zdGFsbCBhd3NjbGkKUlVOIC0tbW91bnQ9dHlwZT1zZWNyZXQsaWQ9YXdzLHRhcmdldD0vcm9vdC8uYXdzL2NyZWRlbnRpYWxzIFwKICBhd3MgczMgY3AgczM6Ly8uLi4gLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pip install awscli<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>secret,id<span class=o>=</span>aws,target<span class=o>=</span>/root/.aws/credentials <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  aws s3 cp s3://... ...</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGR4IGJ1aWxkIC0tc2VjcmV0IGlkPWF3cyxzcmM9JEhPTUUvLmF3cy9jcmVkZW50aWFscyAu', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker buildx build --secret <span class=nv>id</span><span class=o>=</span>aws,src<span class=o>=</span><span class=nv>$HOME</span>/.aws/credentials .
</span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=run---mounttypessh><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---mounttypessh">RUN --mount=type=ssh</a></h3><p>This mount type allows the build container to access SSH keys via SSH agents,
with support for passphrases.</p><table><thead><tr><th>Option</th><th>Description</th></tr></thead><tbody><tr><td><code>id</code></td><td>ID of SSH agent socket or key. Defaults to "default".</td></tr><tr><td><code>target</code></td><td>SSH agent socket path. Defaults to <code>/run/buildkit/ssh_agent.${N}</code>.</td></tr><tr><td><code>required</code></td><td>If set to <code>true</code>, the instruction errors out when the key is unavailable. Defaults to <code>false</code>.</td></tr><tr><td><code>mode</code></td><td>File mode for socket in octal. Default <code>0600</code>.</td></tr><tr><td><code>uid</code></td><td>User ID for socket. Default <code>0</code>.</td></tr><tr><td><code>gid</code></td><td>Group ID for socket. Default <code>0</code>.</td></tr></tbody></table><h4 class=scroll-mt-20 id=example-access-to-gitlab><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-access-to-gitlab">Example: access to Gitlab</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpSVU4gYXBrIGFkZCAtLW5vLWNhY2hlIG9wZW5zc2gtY2xpZW50ClJVTiBta2RpciAtcCAtbSAwNzAwIH4vLnNzaCAmJiBzc2gta2V5c2NhbiBnaXRsYWIuY29tID4+IH4vLnNzaC9rbm93bl9ob3N0cwpSVU4gLS1tb3VudD10eXBlPXNzaCBcCiAgc3NoIC1xIC1UIGdpdEBnaXRsYWIuY29tIDI+JjEgfCB0ZWUgL2hlbGxvCiMgIldlbGNvbWUgdG8gR2l0TGFiLCBAR0lUTEFCX1VTRVJOQU1FX0FTU09DSUFURURfV0lUSF9TU0hLRVkiIHNob3VsZCBiZSBwcmludGVkIGhlcmUKIyB3aXRoIHRoZSB0eXBlIG9mIGJ1aWxkIHByb2dyZXNzIGlzIGRlZmluZWQgYXMgYHBsYWluYC4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apk add --no-cache openssh-client<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> mkdir -p -m <span class=m>0700</span> ~/.ssh <span class=o>&amp;&amp;</span> ssh-keyscan gitlab.com &gt;&gt; ~/.ssh/known_hosts<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>type</span><span class=o>=</span>ssh <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  ssh -q -T git@gitlab.com 2&gt;<span class=p>&amp;</span><span class=m>1</span> <span class=p>|</span> tee /hello<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># &#34;Welcome to GitLab, @GITLAB_USERNAME_ASSOCIATED_WITH_SSHKEY&#34; should be printed here</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># with the type of build progress is defined as `plain`.</span></span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'JCBldmFsICQoc3NoLWFnZW50KQokIHNzaC1hZGQgfi8uc3NoL2lkX3JzYQooSW5wdXQgeW91ciBwYXNzcGhyYXNlIGhlcmUpCiQgZG9ja2VyIGJ1aWxkeCBidWlsZCAtLXNzaCBkZWZhdWx0PSRTU0hfQVVUSF9TT0NLIC4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> <span class=nb>eval</span> <span class=k>$(</span>ssh-agent<span class=k>)</span>
</span></span><span class=line><span class=cl><span class=gp>$</span> ssh-add ~/.ssh/id_rsa
</span></span><span class=line><span class=cl><span class=go>(Input your passphrase here)
</span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>$</span> docker buildx build --ssh <span class=nv>default</span><span class=o>=</span><span class=nv>$SSH_AUTH_SOCK</span> .
</span></span></code></pre></div></div></div><p>You can also specify a path to <code>*.pem</code> file on the host directly instead of <code>$SSH_AUTH_SOCK</code>.
However, pem files with passphrases are not supported.</p><h2 class=scroll-mt-20 id=run---network><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---network">RUN --network</a></h2><blockquote><p><strong>Note</strong></p><p>Added in
<a class=link href="index.html#syntax"><code>docker/dockerfile:1.1</code></a></p></blockquote><p><code>RUN --network</code> allows control over which networking environment the command
is run in.</p><p>Syntax: <code>--network=&lt;TYPE></code></p><h3 class=scroll-mt-20 id=network-types><a class="text-black dark:text-white no-underline hover:underline" href="index.html#network-types">Network types</a></h3><table><thead><tr><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><a class=link href="index.html#run---networkdefault"><code>default</code></a> (default)</td><td>Run in the default network.</td></tr><tr><td><a class=link href="index.html#run---networknone"><code>none</code></a></td><td>Run with no network access.</td></tr><tr><td><a class=link href="index.html#run---networkhost"><code>host</code></a></td><td>Run in the host's network environment.</td></tr></tbody></table><h3 class=scroll-mt-20 id=run---networkdefault><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---networkdefault">RUN --network=default</a></h3><p>Equivalent to not supplying a flag at all, the command is run in the default
network for the build.</p><h3 class=scroll-mt-20 id=run---networknone><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---networknone">RUN --network=none</a></h3><p>The command is run with no network access (<code>lo</code> is still available, but is
isolated to this process)</p><h4 class=scroll-mt-20 id=example-isolating-external-effects><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-isolating-external-effects">Example: isolating external effects</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozLjYKQUREIG15cGFja2FnZS50Z3ogd2hlZWxzLwpSVU4gLS1uZXR3b3JrPW5vbmUgcGlwIGluc3RhbGwgLS1maW5kLWxpbmtzIHdoZWVscyBteXBhY2thZ2U=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3.6</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> mypackage.tgz wheels/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --network<span class=o>=</span>none pip install --find-links wheels mypackage</span></span></code></pre></div></div></div><p><code>pip</code> will only be able to install the packages provided in the tarfile, which
can be controlled by an earlier build stage.</p><h3 class=scroll-mt-20 id=run---networkhost><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---networkhost">RUN --network=host</a></h3><p>The command is run in the host's network environment (similar to
<code>docker build --network=host</code>, but on a per-instruction basis)</p><blockquote class=warning><p><strong>Warning</strong></p><p>The use of <code>--network=host</code> is protected by the <code>network.host</code> entitlement,
which needs to be enabled when starting the buildkitd daemon with
<code>--allow-insecure-entitlement network.host</code> flag or in
<a class=link href=https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md target=_blank rel=noopener>buildkitd config<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>,
and for a build request with
<a class=link href="../commandline/buildx_build/index.html#allow" target=_blank rel=noopener><code>--allow network.host</code> flag<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p></blockquote><h2 class=scroll-mt-20 id=run---security><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---security">RUN --security</a></h2><blockquote><p><strong>Note</strong></p><p>Not yet available in stable syntax, use
<a class=link href="index.html#syntax"><code>docker/dockerfile:1-labs</code></a> version.</p></blockquote><h3 class=scroll-mt-20 id=run---securityinsecure><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---securityinsecure">RUN --security=insecure</a></h3><p>With <code>--security=insecure</code>, builder runs the command without sandbox in insecure
mode, which allows to run flows requiring elevated privileges (e.g. containerd).
This is equivalent to running <code>docker run --privileged</code>.</p><blockquote class=warning><p><strong>Warning</strong></p><p>In order to access this feature, entitlement <code>security.insecure</code> should be
enabled when starting the buildkitd daemon with
<code>--allow-insecure-entitlement security.insecure</code> flag or in
<a class=link href=https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md target=_blank rel=noopener>buildkitd config<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>,
and for a build request with
<a class=link href="../commandline/buildx_build/index.html#allow" target=_blank rel=noopener><code>--allow security.insecure</code> flag<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p></blockquote><h4 class=scroll-mt-20 id=example-check-entitlements><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-check-entitlements">Example: check entitlements</a></h4><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MS1sYWJzCkZST00gdWJ1bnR1ClJVTiAtLXNlY3VyaXR5PWluc2VjdXJlIGNhdCAvcHJvYy9zZWxmL3N0YXR1cyB8IGdyZXAgQ2FwRWZm', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1-labs</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --security<span class=o>=</span>insecure cat /proc/self/status <span class=p>|</span> grep CapEff</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'Izg0IDAuMDkzIENhcEVmZjoJMDAwMDAwM2ZmZmZmZmZmZg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-text data-lang=text><span class=line><span class=cl>#84 0.093 CapEff:	0000003fffffffff</span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=run---securitysandbox><a class="text-black dark:text-white no-underline hover:underline" href="index.html#run---securitysandbox">RUN --security=sandbox</a></h3><p>Default sandbox mode can be activated via <code>--security=sandbox</code>, but that is no-op.</p><h2 class=scroll-mt-20 id=cmd><a class="text-black dark:text-white no-underline hover:underline" href="index.html#cmd">CMD</a></h2><p>The <code>CMD</code> instruction sets the command to be executed when running a container
from an image.</p><p>You can specify <code>CMD</code> instructions using
<a class=link href="index.html#shell-and-exec-form">shell or exec forms</a>:</p><ul><li><code>CMD ["executable","param1","param2"]</code> (exec form)</li><li><code>CMD ["param1","param2"]</code> (exec form, as default parameters to <code>ENTRYPOINT</code>)</li><li><code>CMD command param1 param2</code> (shell form)</li></ul><p>There can only be one <code>CMD</code> instruction in a Dockerfile. If you list more than
one <code>CMD</code>, only the last one takes effect.</p><p>The purpose of a <code>CMD</code> is to provide defaults for an executing container. These
defaults can include an executable, or they can omit the executable, in which
case you must specify an <code>ENTRYPOINT</code> instruction as well.</p><p>If you would like your container to run the same executable every time, then
you should consider using <code>ENTRYPOINT</code> in combination with <code>CMD</code>. See
<a class=link href="index.html#entrypoint"><code>ENTRYPOINT</code></a>. If the user specifies arguments to <code>docker run</code>
then they will override the default specified in <code>CMD</code>, but still use the
default <code>ENTRYPOINT</code>.</p><p>If <code>CMD</code> is used to provide default arguments for the <code>ENTRYPOINT</code> instruction,
both the <code>CMD</code> and <code>ENTRYPOINT</code> instructions should be specified in the
<a class=link href="index.html#exec-form">exec form</a>.</p><blockquote><p><strong>Note</strong></p><p>Don't confuse <code>RUN</code> with <code>CMD</code>. <code>RUN</code> actually runs a command and commits
the result; <code>CMD</code> doesn't execute anything at build time, but specifies
the intended command for the image.</p></blockquote><h2 class=scroll-mt-20 id=label><a class="text-black dark:text-white no-underline hover:underline" href="index.html#label">LABEL</a></h2><div class="group relative"><button x-data="{ code: 'TEFCRUwgPGtleT49PHZhbHVlPiA8a2V5Pj08dmFsdWU+IDxrZXk+PTx2YWx1ZT4gLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> &lt;key&gt;<span class=o>=</span>&lt;value&gt; &lt;key&gt;<span class=o>=</span>&lt;value&gt; &lt;key&gt;<span class=o>=</span>&lt;value&gt; ...</span></span></code></pre></div></div></div><p>The <code>LABEL</code> instruction adds metadata to an image. A <code>LABEL</code> is a
key-value pair. To include spaces within a <code>LABEL</code> value, use quotes and
backslashes as you would in command-line parsing. A few usage examples:</p><div class="group relative"><button x-data="{ code: 'TEFCRUwgImNvbS5leGFtcGxlLnZlbmRvciI9IkFDTUUgSW5jb3Jwb3JhdGVkIgpMQUJFTCBjb20uZXhhbXBsZS5sYWJlbC13aXRoLXZhbHVlPSJmb28iCkxBQkVMIHZlcnNpb249IjEuMCIKTEFCRUwgZGVzY3JpcHRpb249IlRoaXMgdGV4dCBpbGx1c3RyYXRlcyBcCnRoYXQgbGFiZWwtdmFsdWVzIGNhbiBzcGFuIG11bHRpcGxlIGxpbmVzLiI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> <span class=s2>&#34;com.example.vendor&#34;</span><span class=o>=</span><span class=s2>&#34;ACME Incorporated&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> com.example.label-with-value<span class=o>=</span><span class=s2>&#34;foo&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> <span class=nv>version</span><span class=o>=</span><span class=s2>&#34;1.0&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>LABEL</span> <span class=nv>description</span><span class=o>=</span><span class=s2>&#34;This text illustrates \
</span></span></span><span class=line><span class=cl><span class=s2>that label-values can span multiple lines.&#34;</span></span></span></code></pre></div></div></div><p>An image can have more than one label. You can specify multiple labels on a
single line. Prior to Docker 1.10, this decreased the size of the final image,
but this is no longer the case. You may still choose to specify multiple labels
in a single instruction, in one of the following two ways:</p><div class="group relative"><button x-data="{ code: 'TEFCRUwgbXVsdGkubGFiZWwxPSJ2YWx1ZTEiIG11bHRpLmxhYmVsMj0idmFsdWUyIiBvdGhlcj0idmFsdWUzIg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> multi.label1<span class=o>=</span><span class=s2>&#34;value1&#34;</span> multi.label2<span class=o>=</span><span class=s2>&#34;value2&#34;</span> <span class=nv>other</span><span class=o>=</span><span class=s2>&#34;value3&#34;</span></span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'TEFCRUwgbXVsdGkubGFiZWwxPSJ2YWx1ZTEiIFwKICAgICAgbXVsdGkubGFiZWwyPSJ2YWx1ZTIiIFwKICAgICAgb3RoZXI9InZhbHVlMyI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> multi.label1<span class=o>=</span><span class=s2>&#34;value1&#34;</span> <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>      multi.label2<span class=o>=</span><span class=s2>&#34;value2&#34;</span> <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>      <span class=nv>other</span><span class=o>=</span><span class=s2>&#34;value3&#34;</span></span></span></code></pre></div></div></div><blockquote><p><strong>Note</strong></p><p>Be sure to use double quotes and not single quotes. Particularly when you are
using string interpolation (e.g. <code>LABEL example="foo-$ENV_VAR"</code>), single
quotes will take the string as is without unpacking the variable's value.</p></blockquote><p>Labels included in base or parent images (images in the <code>FROM</code> line) are
inherited by your image. If a label already exists but with a different value,
the most-recently-applied value overrides any previously-set value.</p><p>To view an image's labels, use the <code>docker image inspect</code> command. You can use
the <code>--format</code> option to show just the labels;</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgaW1hZ2UgaW5zcGVjdCAtLWZvcm1hdD0ne3tqc29uIC5Db25maWcuTGFiZWxzfX0nIG15aW1hZ2U=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker image inspect --format<span class=o>=</span><span class=s1>&#39;{{json .Config.Labels}}&#39;</span> myimage
</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'ewogICJjb20uZXhhbXBsZS52ZW5kb3IiOiAiQUNNRSBJbmNvcnBvcmF0ZWQiLAogICJjb20uZXhhbXBsZS5sYWJlbC13aXRoLXZhbHVlIjogImZvbyIsCiAgInZlcnNpb24iOiAiMS4wIiwKICAiZGVzY3JpcHRpb24iOiAiVGhpcyB0ZXh0IGlsbHVzdHJhdGVzIHRoYXQgbGFiZWwtdmFsdWVzIGNhbiBzcGFuIG11bHRpcGxlIGxpbmVzLiIsCiAgIm11bHRpLmxhYmVsMSI6ICJ2YWx1ZTEiLAogICJtdWx0aS5sYWJlbDIiOiAidmFsdWUyIiwKICAib3RoZXIiOiAidmFsdWUzIgp9', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-json data-lang=json><span class=line><span class=cl><span class=p>{</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;com.example.vendor&#34;</span><span class=p>:</span> <span class=s2>&#34;ACME Incorporated&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;com.example.label-with-value&#34;</span><span class=p>:</span> <span class=s2>&#34;foo&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;version&#34;</span><span class=p>:</span> <span class=s2>&#34;1.0&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;description&#34;</span><span class=p>:</span> <span class=s2>&#34;This text illustrates that label-values can span multiple lines.&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;multi.label1&#34;</span><span class=p>:</span> <span class=s2>&#34;value1&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;multi.label2&#34;</span><span class=p>:</span> <span class=s2>&#34;value2&#34;</span><span class=p>,</span>
</span></span><span class=line><span class=cl>  <span class=nt>&#34;other&#34;</span><span class=p>:</span> <span class=s2>&#34;value3&#34;</span>
</span></span><span class=line><span class=cl><span class=p>}</span></span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=maintainer-deprecated><a class="text-black dark:text-white no-underline hover:underline" href="index.html#maintainer-deprecated">MAINTAINER (deprecated)</a></h2><div class="group relative"><button x-data="{ code: 'TUFJTlRBSU5FUiA8bmFtZT4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>MAINTAINER</span><span class=s> &lt;name&gt;</span></span></span></code></pre></div></div></div><p>The <code>MAINTAINER</code> instruction sets the <em>Author</em> field of the generated images.
The <code>LABEL</code> instruction is a much more flexible version of this and you should use
it instead, as it enables setting any metadata you require, and can be viewed
easily, for example with <code>docker inspect</code>. To set a label corresponding to the
<code>MAINTAINER</code> field you could use:</p><div class="group relative"><button x-data="{ code: 'TEFCRUwgb3JnLm9wZW5jb250YWluZXJzLmltYWdlLmF1dGhvcnM9IlN2ZW5Eb3dpZGVpdEBob21lLm9yZy5hdSI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>LABEL</span> org.opencontainers.image.authors<span class=o>=</span><span class=s2>&#34;SvenDowideit@home.org.au&#34;</span></span></span></code></pre></div></div></div><p>This will then be visible from <code>docker inspect</code> with the other labels.</p><h2 class=scroll-mt-20 id=expose><a class="text-black dark:text-white no-underline hover:underline" href="index.html#expose">EXPOSE</a></h2><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDxwb3J0PiBbPHBvcnQ+Lzxwcm90b2NvbD4uLi5d', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> &lt;port&gt; [&lt;port&gt;/&lt;protocol&gt;...]</span></span></span></code></pre></div></div></div><p>The <code>EXPOSE</code> instruction informs Docker that the container listens on the
specified network ports at runtime. You can specify whether the port listens on
TCP or UDP, and the default is TCP if you don't specify a protocol.</p><p>The <code>EXPOSE</code> instruction doesn't actually publish the port. It functions as a
type of documentation between the person who builds the image and the person who
runs the container, about which ports are intended to be published. To
publish the port when running the container, use the <code>-p</code> flag on <code>docker run</code>
to publish and map one or more ports, or the <code>-P</code> flag to publish all exposed
ports and map them to high-order ports.</p><p>By default, <code>EXPOSE</code> assumes TCP. You can also specify UDP:</p><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDgwL3VkcA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> 80/udp</span></span></span></code></pre></div></div></div><p>To expose on both TCP and UDP, include two lines:</p><div class="group relative"><button x-data="{ code: 'RVhQT1NFIDgwL3RjcApFWFBPU0UgODAvdWRw', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>EXPOSE</span><span class=s> 80/tcp</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>EXPOSE</span><span class=s> 80/udp</span></span></span></code></pre></div></div></div><p>In this case, if you use <code>-P</code> with <code>docker run</code>, the port will be exposed once
for TCP and once for UDP. Remember that <code>-P</code> uses an ephemeral high-ordered host
port on the host, so TCP and UDP doesn't use the same port.</p><p>Regardless of the <code>EXPOSE</code> settings, you can override them at runtime by using
the <code>-p</code> flag. For example</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1wIDgwOjgwL3RjcCAtcCA4MDo4MC91ZHAgLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -p 80:80/tcp -p 80:80/udp ...
</span></span></code></pre></div></div></div><p>To set up port redirection on the host system, see
<a class=link href="../../../reference/run/index.html#expose-incoming-ports" target=_blank rel=noopener>using the -P flag<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.
The <code>docker network</code> command supports creating networks for communication among
containers without the need to expose or publish specific ports, because the
containers connected to the network can communicate with each other over any
port. For detailed information, see the
<a class=link href="../../userguide/networking/index.html" target=_blank rel=noopener>overview of this feature<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p><h2 class=scroll-mt-20 id=env><a class="text-black dark:text-white no-underline hover:underline" href="index.html#env">ENV</a></h2><div class="group relative"><button x-data="{ code: 'RU5WIDxrZXk+PTx2YWx1ZT4gLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> &lt;key&gt;<span class=o>=</span>&lt;value&gt; ...</span></span></code></pre></div></div></div><p>The <code>ENV</code> instruction sets the environment variable <code>&lt;key></code> to the value
<code>&lt;value></code>. This value will be in the environment for all subsequent instructions
in the build stage and can be
<a class=link href="index.html#environment-replacement">replaced inline</a> in
many as well. The value will be interpreted for other environment variables, so
quote characters will be removed if they are not escaped. Like command line parsing,
quotes and backslashes can be used to include spaces within values.</p><p>Example:</p><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX05BTUU9IkpvaG4gRG9lIgpFTlYgTVlfRE9HPVJleFwgVGhlXCBEb2cKRU5WIE1ZX0NBVD1mbHVmZnk=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>MY_NAME</span><span class=o>=</span><span class=s2>&#34;John Doe&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>MY_DOG</span><span class=o>=</span>Rex<span class=se>\ </span>The<span class=se>\ </span>Dog<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>MY_CAT</span><span class=o>=</span>fluffy</span></span></code></pre></div></div></div><p>The <code>ENV</code> instruction allows for multiple <code>&lt;key>=&lt;value> ...</code> variables to be set
at one time, and the example below will yield the same net results in the final
image:</p><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX05BTUU9IkpvaG4gRG9lIiBNWV9ET0c9UmV4XCBUaGVcIERvZyBcCiAgICBNWV9DQVQ9Zmx1ZmZ5', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>MY_NAME</span><span class=o>=</span><span class=s2>&#34;John Doe&#34;</span> <span class=nv>MY_DOG</span><span class=o>=</span>Rex<span class=se>\ </span>The<span class=se>\ </span>Dog <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>    <span class=nv>MY_CAT</span><span class=o>=</span>fluffy</span></span></code></pre></div></div></div><p>The environment variables set using <code>ENV</code> will persist when a container is run
from the resulting image. You can view the values using <code>docker inspect</code>, and
change them using <code>docker run --env &lt;key>=&lt;value></code>.</p><p>A stage inherits any environment variables that were set using <code>ENV</code> by its
parent stage or any ancestor. Refer
<a class=link href="../../../build/building/multi-stage.html" target=_blank rel=noopener>here<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
for more on multi-staged builds.</p><p>Environment variable persistence can cause unexpected side effects. For example,
setting <code>ENV DEBIAN_FRONTEND=noninteractive</code> changes the behavior of <code>apt-get</code>,
and may confuse users of your image.</p><p>If an environment variable is only needed during build, and not in the final
image, consider setting a value for a single command instead:</p><div class="group relative"><button x-data="{ code: 'UlVOIERFQklBTl9GUk9OVEVORD1ub25pbnRlcmFjdGl2ZSBhcHQtZ2V0IHVwZGF0ZSAmJiBhcHQtZ2V0IGluc3RhbGwgLXkgLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=nv>DEBIAN_FRONTEND</span><span class=o>=</span>noninteractive apt-get update <span class=o>&amp;&amp;</span> apt-get install -y ...</span></span></code></pre></div></div></div><p>Or using
<a class=link href="index.html#arg"><code>ARG</code></a>, which is not persisted in the final image:</p><div class="group relative"><button x-data="{ code: 'QVJHIERFQklBTl9GUk9OVEVORD1ub25pbnRlcmFjdGl2ZQpSVU4gYXB0LWdldCB1cGRhdGUgJiYgYXB0LWdldCBpbnN0YWxsIC15IC4uLg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>DEBIAN_FRONTEND</span><span class=o>=</span>noninteractive
</span></span><span class=line><span class=cl><span class=k>RUN</span> apt-get update <span class=o>&amp;&amp;</span> apt-get install -y ...</span></span></code></pre></div></div></div><blockquote><p><strong>Alternative syntax</strong></p><p>The <code>ENV</code> instruction also allows an alternative syntax <code>ENV &lt;key> &lt;value></code>,
omitting the <code>=</code>. For example:</p><div class="group relative"><button x-data="{ code: 'RU5WIE1ZX1ZBUiBteS12YWx1ZQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> MY_VAR my-value</span></span></code></pre></div></div></div><p>This syntax does not allow for multiple environment-variables to be set in a
single <code>ENV</code> instruction, and can be confusing. For example, the following
sets a single environment variable (<code>ONE</code>) with value <code>"TWO= THREE=world"</code>:</p><div class="group relative"><button x-data="{ code: 'RU5WIE9ORSBUV089IFRIUkVFPXdvcmxk', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> ONE <span class=nv>TWO</span><span class=o>=</span> <span class=nv>THREE</span><span class=o>=</span>world</span></span></code></pre></div></div></div><p>The alternative syntax is supported for backward compatibility, but discouraged
for the reasons outlined above, and may be removed in a future release.</p></blockquote><h2 class=scroll-mt-20 id=add><a class="text-black dark:text-white no-underline hover:underline" href="index.html#add">ADD</a></h2><p>ADD has two forms:</p><div class="group relative"><button x-data="{ code: 'QUREIFstLWNob3duPTx1c2VyPjo8Z3JvdXA+XSBbLS1jaG1vZD08cGVybXM+XSBbLS1jaGVja3N1bT08Y2hlY2tzdW0+XSA8c3JjPi4uLiA8ZGVzdD4KQUREIFstLWNob3duPTx1c2VyPjo8Z3JvdXA+XSBbLS1jaG1vZD08cGVybXM+XSBbIjxzcmM+IiwuLi4gIjxkZXN0PiJd', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> <span class=o>[</span>--chown<span class=o>=</span>&lt;user&gt;:&lt;group&gt;<span class=o>]</span> <span class=o>[</span>--chmod<span class=o>=</span>&lt;perms&gt;<span class=o>]</span> <span class=o>[</span>--checksum<span class=o>=</span>&lt;checksum&gt;<span class=o>]</span> &lt;src&gt;... &lt;dest&gt;<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> <span class=o>[</span>--chown<span class=o>=</span>&lt;user&gt;:&lt;group&gt;<span class=o>]</span> <span class=o>[</span>--chmod<span class=o>=</span>&lt;perms&gt;<span class=o>]</span> <span class=o>[</span><span class=s2>&#34;&lt;src&gt;&#34;</span>,... <span class=s2>&#34;&lt;dest&gt;&#34;</span><span class=o>]</span></span></span></code></pre></div></div></div><p>The latter form is required for paths containing whitespace.</p><blockquote><p><strong>Note</strong></p><p>The <code>--chown</code> and <code>--chmod</code> features are only supported on Dockerfiles used to build Linux containers,
and doesn't work on Windows containers. Since user and group ownership concepts do
not translate between Linux and Windows, the use of <code>/etc/passwd</code> and <code>/etc/group</code> for
translating user and group names to IDs restricts this feature to only be viable
for Linux OS-based containers.</p></blockquote><blockquote><p><strong>Note</strong></p><p><code>--chmod</code> is supported since
<a class=link href="../../../build/buildkit/dockerfile-frontend/index.html" target=_blank rel=noopener>Dockerfile 1.3<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.
Only octal notation is currently supported. Non-octal support is tracked in
<a class=link href=https://github.com/moby/buildkit/issues/1951 target=_blank rel=noopener>moby/buildkit#1951<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>.</p></blockquote><p>The <code>ADD</code> instruction copies new files, directories or remote file URLs from <code>&lt;src></code>
and adds them to the filesystem of the image at the path <code>&lt;dest></code>.</p><p>Multiple <code>&lt;src></code> resources may be specified but if they are files or
directories, their paths are interpreted as relative to the source of
the context of the build.</p><p>Each <code>&lt;src></code> may contain wildcards and matching will be done using Go's
<a class=link href=https://golang.org/pkg/path/filepath#Match target=_blank rel=noopener>filepath.Match<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> rules. For example:</p><p>To add all files starting with "hom":</p><div class="group relative"><button x-data="{ code: 'QUREIGhvbSogL215ZGlyLw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> hom* /mydir/</span></span></code></pre></div></div></div><p>In the example below, <code>?</code> is replaced with any single character, e.g., "home.txt".</p><div class="group relative"><button x-data="{ code: 'QUREIGhvbT8udHh0IC9teWRpci8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> hom?.txt /mydir/</span></span></code></pre></div></div></div><p>The <code>&lt;dest></code> is an absolute path, or a path relative to <code>WORKDIR</code>, into which
the source will be copied inside the destination container.</p><p>The example below uses a relative path, and adds "test.txt" to <code>&lt;WORKDIR>/relativeDir/</code>:</p><div class="group relative"><button x-data="{ code: 'QUREIHRlc3QudHh0IHJlbGF0aXZlRGlyLw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> test.txt relativeDir/</span></span></code></pre></div></div></div><p>Whereas this example uses an absolute path, and adds "test.txt" to <code>/absoluteDir/</code></p><div class="group relative"><button x-data="{ code: 'QUREIHRlc3QudHh0IC9hYnNvbHV0ZURpci8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> test.txt /absoluteDir/</span></span></code></pre></div></div></div><p>When adding files or directories that contain special characters (such as <code>[</code>
and <code>]</code>), you need to escape those paths following the Golang rules to prevent
them from being treated as a matching pattern. For example, to add a file
named <code>arr[0].txt</code>, use the following;</p><div class="group relative"><button x-data="{ code: 'QUREIGFycltbXTBdLnR4dCAvbXlkaXIv', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> arr<span class=o>[[]</span>0<span class=o>]</span>.txt /mydir/</span></span></code></pre></div></div></div><p>All new files and directories are created with a UID and GID of 0, unless the
optional <code>--chown</code> flag specifies a given username, groupname, or UID/GID
combination to request specific ownership of the content added. The
format of the <code>--chown</code> flag allows for either username and groupname strings
or direct integer UID and GID in any combination. Providing a username without
groupname or a UID without GID will use the same numeric UID as the GID. If a
username or groupname is provided, the container's root filesystem
<code>/etc/passwd</code> and <code>/etc/group</code> files will be used to perform the translation
from name to integer UID or GID respectively. The following examples show
valid definitions for the <code>--chown</code> flag:</p><div class="group relative"><button x-data="{ code: 'QUREIC0tY2hvd249NTU6bXlncm91cCBmaWxlcyogL3NvbWVkaXIvCkFERCAtLWNob3duPWJpbiBmaWxlcyogL3NvbWVkaXIvCkFERCAtLWNob3duPTEgZmlsZXMqIC9zb21lZGlyLwpBREQgLS1jaG93bj0xMDoxMSBmaWxlcyogL3NvbWVkaXIvCkFERCAtLWNob3duPW15dXNlcjpteWdyb3VwIC0tY2htb2Q9NjU1IGZpbGVzKiAvc29tZWRpci8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> --chown<span class=o>=</span>55:mygroup files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --chown<span class=o>=</span>bin files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --chown<span class=o>=</span><span class=m>1</span> files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --chown<span class=o>=</span>10:11 files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --chown<span class=o>=</span>myuser:mygroup --chmod<span class=o>=</span><span class=m>655</span> files* /somedir/</span></span></code></pre></div></div></div><p>If the container root filesystem doesn't contain either <code>/etc/passwd</code> or
<code>/etc/group</code> files and either user or group names are used in the <code>--chown</code>
flag, the build will fail on the <code>ADD</code> operation. Using numeric IDs requires
no lookup and doesn't depend on container root filesystem content.</p><p>In the case where <code>&lt;src></code> is a remote file URL, the destination will
have permissions of 600. If the remote file being retrieved has an HTTP
<code>Last-Modified</code> header, the timestamp from that header will be used
to set the <code>mtime</code> on the destination file. However, like any other file
processed during an <code>ADD</code>, <code>mtime</code> isn't included in the determination
of whether or not the file has changed and the cache should be updated.</p><blockquote><p><strong>Note</strong></p><p>If you build by passing a Dockerfile through STDIN (<code>docker build - &lt; somefile</code>), there is no build context, so the Dockerfile
can only contain a URL based <code>ADD</code> instruction. You can also pass a
compressed archive through STDIN: (<code>docker build - &lt; archive.tar.gz</code>),
the Dockerfile at the root of the archive and the rest of the
archive will be used as the context of the build.</p></blockquote><p>If your URL files are protected using authentication, you need to use <code>RUN wget</code>,
<code>RUN curl</code> or use another tool from within the container as the <code>ADD</code> instruction
doesn't support authentication.</p><blockquote><p><strong>Note</strong></p><p>The first encountered <code>ADD</code> instruction will invalidate the cache for all
following instructions from the Dockerfile if the contents of <code>&lt;src></code> have
changed. This includes invalidating the cache for <code>RUN</code> instructions.
See the
<a class=link href="../../userguide/eng-image/dockerfile_best-practices/index.html#leverage-build-cache" target=_blank rel=noopener>Dockerfile Best Practices
guide – Leverage build cache<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
for more information.</p></blockquote><p><code>ADD</code> obeys the following rules:</p><ul><li><p>The <code>&lt;src></code> path must be inside the build context;
you can't use <code>ADD ../something /something</code>, because the builder can only
access files from the context, and <code>../something</code> specifies a parent file or
directory of the build context root.</p></li><li><p>If <code>&lt;src></code> is a URL and <code>&lt;dest></code> does end with a trailing slash, then the
filename is inferred from the URL and the file is downloaded to
<code>&lt;dest>/&lt;filename></code>. For instance, <code>ADD http://example.com/foobar /</code> would
create the file <code>/foobar</code>. The URL must have a nontrivial path so that an
appropriate filename can be discovered in this case (<code>http://example.com</code>
doesn't work).</p></li><li><p>If <code>&lt;src></code> is a directory, the entire contents of the directory are copied,
including filesystem metadata.</p><blockquote><p><strong>Note</strong></p><p>The directory itself isn't copied, only its contents.</p></blockquote></li><li><p>If <code>&lt;src></code> is a local <code>tar</code> archive in a recognized compression format
(<code>identity</code>, <code>gzip</code>, <code>bzip2</code> or <code>xz</code>) then it's unpacked as a directory. Resources
from remote URLs aren't decompressed. When a directory is copied or
unpacked, it has the same behavior as <code>tar -x</code>. The result is the union of:</p><ol><li>Whatever existed at the destination path and</li><li>The contents of the source tree, with conflicts resolved in favor
of "2." on a file-by-file basis.</li></ol><blockquote><p><strong>Note</strong></p><p>Whether a file is identified as a recognized compression format or not
is done solely based on the contents of the file, not the name of the file.
For example, if an empty file happens to end with <code>.tar.gz</code> this isn't
recognized as a compressed file and doesn't generate any kind of
decompression error message, rather the file will simply be copied to the
destination.</p></blockquote></li><li><p>If <code>&lt;src></code> is any other kind of file, it's copied individually along with
its metadata. In this case, if <code>&lt;dest></code> ends with a trailing slash <code>/</code>, it
will be considered a directory and the contents of <code>&lt;src></code> will be written
at <code>&lt;dest>/base(&lt;src>)</code>.</p></li><li><p>If multiple <code>&lt;src></code> resources are specified, either directly or due to the
use of a wildcard, then <code>&lt;dest></code> must be a directory, and it must end with
a slash <code>/</code>.</p></li><li><p>If <code>&lt;src></code> is a file, and <code>&lt;dest></code> doesn't end with a trailing slash,
the contents of <code>&lt;src></code> will be written as filename <code>&lt;dest></code>.</p></li><li><p>If <code>&lt;dest></code> doesn't exist, it's created, along with all missing directories
in its path.</p></li></ul><h3 class=scroll-mt-20 id=verifying-a-remote-file-checksum-add---checksumchecksum-http-src-dest><a class="text-black dark:text-white no-underline hover:underline" href="index.html#verifying-a-remote-file-checksum-add---checksumchecksum-http-src-dest">Verifying a remote file checksum ADD --checksum=&lt;checksum> &lt;http src> &lt;dest></a></h3><p>The checksum of a remote file can be verified with the <code>--checksum</code> flag:</p><div class="group relative"><button x-data="{ code: 'QUREIC0tY2hlY2tzdW09c2hhMjU2OjI0NDU0ZjgzMGNkYjU3MWUyYzRhZDE1NDgxMTE5YzQzYjNjYWZkNDhkZDg2OWE5YjI5NDVkMTAzNmQxZGM2OGQgaHR0cHM6Ly9taXJyb3JzLmVkZ2Uua2VybmVsLm9yZy9wdWIvbGludXgva2VybmVsL0hpc3RvcmljL2xpbnV4LTAuMDEudGFyLmd6IC8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> --checksum<span class=o>=</span>sha256:24454f830cdb571e2c4ad15481119c43b3cafd48dd869a9b2945d1036d1dc68d https://mirrors.edge.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz /</span></span></code></pre></div></div></div><p>The <code>--checksum</code> flag only supports HTTP sources currently.</p><h3 class=scroll-mt-20 id=adding-a-git-repository-add-git-ref-dir><a class="text-black dark:text-white no-underline hover:underline" href="index.html#adding-a-git-repository-add-git-ref-dir">Adding a Git repository ADD &lt;git ref> &lt;dir></a></h3><p>This form allows adding a Git repository to an image directly, without using the <code>git</code> command inside the image:</p><div class="group relative"><button x-data="{ code: 'QUREIFstLWtlZXAtZ2l0LWRpcj08Ym9vbGVhbj5dIDxnaXQgcmVmPiA8ZGlyPg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ADD</span> <span class=o>[</span>--keep-git-dir<span class=o>=</span>&lt;boolean&gt;<span class=o>]</span> &lt;git ref&gt; &lt;dir&gt;</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBREQgLS1rZWVwLWdpdC1kaXI9dHJ1ZSBodHRwczovL2dpdGh1Yi5jb20vbW9ieS9idWlsZGtpdC5naXQjdjAuMTAuMSAvYnVpbGRraXQ=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> --keep-git-dir<span class=o>=</span><span class=nb>true</span> https://github.com/moby/buildkit.git#v0.10.1 /buildkit</span></span></code></pre></div></div></div><p>The <code>--keep-git-dir=true</code> flag adds the <code>.git</code> directory. This flag defaults to false.</p><h3 class=scroll-mt-20 id=adding-a-private-git-repository><a class="text-black dark:text-white no-underline hover:underline" href="index.html#adding-a-private-git-repository">Adding a private git repository</a></h3><p>To add a private repo via SSH, create a Dockerfile with the following form:</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBREQgZ2l0QGdpdC5leGFtcGxlLmNvbTpmb28vYmFyLmdpdCAvYmFy', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> git@git.example.com:foo/bar.git /bar</span></span></code></pre></div></div></div><p>This Dockerfile can be built with <code>docker build --ssh</code> or <code>buildctl build --ssh</code>, e.g.,</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1zc2ggZGVmYXVsdA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --ssh default
</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'JCBidWlsZGN0bCBidWlsZCAtLWZyb250ZW5kPWRvY2tlcmZpbGUudjAgLS1sb2NhbCBjb250ZXh0PS4gLS1sb2NhbCBkb2NrZXJmaWxlPS4gLS1zc2ggZGVmYXVsdA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> buildctl build --frontend<span class=o>=</span>dockerfile.v0 --local <span class=nv>context</span><span class=o>=</span>. --local <span class=nv>dockerfile</span><span class=o>=</span>. --ssh default
</span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=add---link><a class="text-black dark:text-white no-underline hover:underline" href="index.html#add---link">ADD --link</a></h2><p>See
<a class=link href="index.html#copy---link"><code>COPY --link</code></a>.</p><h2 class=scroll-mt-20 id=copy><a class="text-black dark:text-white no-underline hover:underline" href="index.html#copy">COPY</a></h2><p>COPY has two forms:</p><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1jaG93bj08dXNlcj46PGdyb3VwPl0gWy0tY2htb2Q9PHBlcm1zPl0gPHNyYz4uLi4gPGRlc3Q+CkNPUFkgWy0tY2hvd249PHVzZXI+Ojxncm91cD5dIFstLWNobW9kPTxwZXJtcz5dIFsiPHNyYz4iLC4uLiAiPGRlc3Q+Il0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--chown<span class=o>=</span>&lt;user&gt;:&lt;group&gt;<span class=o>]</span> <span class=o>[</span>--chmod<span class=o>=</span>&lt;perms&gt;<span class=o>]</span> &lt;src&gt;... &lt;dest&gt;<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> <span class=o>[</span>--chown<span class=o>=</span>&lt;user&gt;:&lt;group&gt;<span class=o>]</span> <span class=o>[</span>--chmod<span class=o>=</span>&lt;perms&gt;<span class=o>]</span> <span class=o>[</span><span class=s2>&#34;&lt;src&gt;&#34;</span>,... <span class=s2>&#34;&lt;dest&gt;&#34;</span><span class=o>]</span></span></span></code></pre></div></div></div><p>This latter form is required for paths containing whitespace</p><blockquote><p><strong>Note</strong></p><p>The <code>--chown</code> and <code>--chmod</code> features are only supported on Dockerfiles used to build Linux containers,
and doesn't work on Windows containers. Since user and group ownership concepts do
not translate between Linux and Windows, the use of <code>/etc/passwd</code> and <code>/etc/group</code> for
translating user and group names to IDs restricts this feature to only be viable for
Linux OS-based containers.</p></blockquote><p>The <code>COPY</code> instruction copies new files or directories from <code>&lt;src></code>
and adds them to the filesystem of the container at the path <code>&lt;dest></code>.</p><p>Multiple <code>&lt;src></code> resources may be specified but the paths of files and
directories will be interpreted as relative to the source of the context
of the build.</p><p>Each <code>&lt;src></code> may contain wildcards and matching will be done using Go's
<a class=link href=https://golang.org/pkg/path/filepath#Match target=_blank rel=noopener>filepath.Match<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> rules. For example:</p><p>To add all files starting with "hom":</p><div class="group relative"><button x-data="{ code: 'Q09QWSBob20qIC9teWRpci8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> hom* /mydir/</span></span></code></pre></div></div></div><p>In the example below, <code>?</code> is replaced with any single character, e.g., "home.txt".</p><div class="group relative"><button x-data="{ code: 'Q09QWSBob20/LnR4dCAvbXlkaXIv', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> hom?.txt /mydir/</span></span></code></pre></div></div></div><p>The <code>&lt;dest></code> is an absolute path, or a path relative to <code>WORKDIR</code>, into which
the source will be copied inside the destination container.</p><p>The example below uses a relative path, and adds "test.txt" to <code>&lt;WORKDIR>/relativeDir/</code>:</p><div class="group relative"><button x-data="{ code: 'Q09QWSB0ZXN0LnR4dCByZWxhdGl2ZURpci8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> test.txt relativeDir/</span></span></code></pre></div></div></div><p>Whereas this example uses an absolute path, and adds "test.txt" to <code>/absoluteDir/</code></p><div class="group relative"><button x-data="{ code: 'Q09QWSB0ZXN0LnR4dCAvYWJzb2x1dGVEaXIv', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> test.txt /absoluteDir/</span></span></code></pre></div></div></div><p>When copying files or directories that contain special characters (such as <code>[</code>
and <code>]</code>), you need to escape those paths following the Golang rules to prevent
them from being treated as a matching pattern. For example, to copy a file
named <code>arr[0].txt</code>, use the following;</p><div class="group relative"><button x-data="{ code: 'Q09QWSBhcnJbW10wXS50eHQgL215ZGlyLw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> arr<span class=o>[[]</span>0<span class=o>]</span>.txt /mydir/</span></span></code></pre></div></div></div><p>All new files and directories are created with a UID and GID of 0, unless the
optional <code>--chown</code> flag specifies a given username, groupname, or UID/GID
combination to request specific ownership of the copied content. The
format of the <code>--chown</code> flag allows for either username and groupname strings
or direct integer UID and GID in any combination. Providing a username without
groupname or a UID without GID will use the same numeric UID as the GID. If a
username or groupname is provided, the container's root filesystem
<code>/etc/passwd</code> and <code>/etc/group</code> files will be used to perform the translation
from name to integer UID or GID respectively. The following examples show
valid definitions for the <code>--chown</code> flag:</p><div class="group relative"><button x-data="{ code: 'Q09QWSAtLWNob3duPTU1Om15Z3JvdXAgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249YmluIGZpbGVzKiAvc29tZWRpci8KQ09QWSAtLWNob3duPTEgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249MTA6MTEgZmlsZXMqIC9zb21lZGlyLwpDT1BZIC0tY2hvd249bXl1c2VyOm15Z3JvdXAgLS1jaG1vZD02NDQgZmlsZXMqIC9zb21lZGlyLw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> --chown<span class=o>=</span>55:mygroup files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>bin files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span><span class=m>1</span> files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>10:11 files* /somedir/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --chown<span class=o>=</span>myuser:mygroup --chmod<span class=o>=</span><span class=m>644</span> files* /somedir/</span></span></code></pre></div></div></div><p>If the container root filesystem doesn't contain either <code>/etc/passwd</code> or
<code>/etc/group</code> files and either user or group names are used in the <code>--chown</code>
flag, the build will fail on the <code>COPY</code> operation. Using numeric IDs requires
no lookup and does not depend on container root filesystem content.</p><blockquote><p><strong>Note</strong></p><p>If you build using STDIN (<code>docker build - &lt; somefile</code>), there is no
build context, so <code>COPY</code> can't be used.</p></blockquote><p>Optionally <code>COPY</code> accepts a flag <code>--from=&lt;name></code> that can be used to set
the source location to a previous build stage (created with <code>FROM .. AS &lt;name></code>)
that will be used instead of a build context sent by the user. In case a build
stage with a specified name can't be found an image with the same name is
attempted to be used instead.</p><p><code>COPY</code> obeys the following rules:</p><ul><li><p>The <code>&lt;src></code> path must be inside the build context;
you can't use <code>COPY ../something /something</code>, because the builder can only
access files from the context, and <code>../something</code> specifies a parent file or
directory of the build context root.</p></li><li><p>If <code>&lt;src></code> is a directory, the entire contents of the directory are copied,
including filesystem metadata.</p><blockquote><p><strong>Note</strong></p><p>The directory itself isn't copied, only its contents.</p></blockquote></li><li><p>If <code>&lt;src></code> is any other kind of file, it's copied individually along with
its metadata. In this case, if <code>&lt;dest></code> ends with a trailing slash <code>/</code>, it
will be considered a directory and the contents of <code>&lt;src></code> will be written
at <code>&lt;dest>/base(&lt;src>)</code>.</p></li><li><p>If multiple <code>&lt;src></code> resources are specified, either directly or due to the
use of a wildcard, then <code>&lt;dest></code> must be a directory, and it must end with
a slash <code>/</code>.</p></li><li><p>If <code>&lt;src></code> is a file, and <code>&lt;dest></code> doesn't end with a trailing slash,
the contents of <code>&lt;src></code> will be written as filename <code>&lt;dest></code>.</p></li><li><p>If <code>&lt;dest></code> doesn't exist, it's created, along with all missing directories
in its path.</p></li></ul><blockquote><p><strong>Note</strong></p><p>The first encountered <code>COPY</code> instruction will invalidate the cache for all
following instructions from the Dockerfile if the contents of <code>&lt;src></code> have
changed. This includes invalidating the cache for <code>RUN</code> instructions.
See the
<a class=link href="../../userguide/eng-image/dockerfile_best-practices/index.html#leverage-build-cache" target=_blank rel=noopener>Dockerfile Best Practices
guide – Leverage build cache<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
for more information.</p></blockquote><h2 class=scroll-mt-20 id=copy---link><a class="text-black dark:text-white no-underline hover:underline" href="index.html#copy---link">COPY --link</a></h2><blockquote><p><strong>Note</strong></p><p>Added in
<a class=link href="index.html#syntax"><code>docker/dockerfile:1.4</code></a></p></blockquote><p>Enabling this flag in <code>COPY</code> or <code>ADD</code> commands allows you to copy files with
enhanced semantics where your files remain independent on their own layer and
don't get invalidated when commands on previous layers are changed.</p><p>When <code>--link</code> is used your source files are copied into an empty destination
directory. That directory is turned into a layer that is linked on top of your
previous state.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpDT1BZIC0tbGluayAvZm9vIC9iYXI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --link /foo /bar</span></span></code></pre></div></div></div><p>Is equivalent of doing two builds:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBhbHBpbmU=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> alpine</span></span></span></code></pre></div></div></div><p>and</p><div class="group relative"><button x-data="{ code: 'RlJPTSBzY3JhdGNoCkNPUFkgL2ZvbyAvYmFy', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> scratch</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> /foo /bar</span></span></code></pre></div></div></div><p>and merging all the layers of both images together.</p><h3 class=scroll-mt-20 id=benefits-of-using---link><a class="text-black dark:text-white no-underline hover:underline" href="index.html#benefits-of-using---link">Benefits of using --link</a></h3><p>Use <code>--link</code> to reuse already built layers in subsequent builds with
<code>--cache-from</code> even if the previous layers have changed. This is especially
important for multi-stage builds where a <code>COPY --from</code> statement would
previously get invalidated if any previous commands in the same stage changed,
causing the need to rebuild the intermediate stages again. With <code>--link</code> the
layer the previous build generated is reused and merged on top of the new
layers. This also means you can easily rebase your images when the base images
receive updates, without having to execute the whole build again. In backends
that support it, BuildKit can do this rebase action without the need to push or
pull any layers between the client and the registry. BuildKit will detect this
case and only create new image manifest that contains the new layers and old
layers in correct order.</p><p>The same behavior where BuildKit can avoid pulling down the base image can also
happen when using <code>--link</code> and no other commands that would require access to
the files in the base image. In that case BuildKit will only build the layers
for the <code>COPY</code> commands and push them to the registry directly on top of the
layers of the base image.</p><h3 class=scroll-mt-20 id=incompatibilities-with---linkfalse><a class="text-black dark:text-white no-underline hover:underline" href="index.html#incompatibilities-with---linkfalse">Incompatibilities with --link=false</a></h3><p>When using <code>--link</code> the <code>COPY/ADD</code> commands are not allowed to read any files
from the previous state. This means that if in previous state the destination
directory was a path that contained a symlink, <code>COPY/ADD</code> can not follow it.
In the final image the destination path created with <code>--link</code> will always be a
path containing only directories.</p><p>If you don't rely on the behavior of following symlinks in the destination
path, using <code>--link</code> is always recommended. The performance of <code>--link</code> is
equivalent or better than the default behavior and, it creates much better
conditions for cache reuse.</p><h2 class=scroll-mt-20 id=copy---parents><a class="text-black dark:text-white no-underline hover:underline" href="index.html#copy---parents">COPY --parents</a></h2><blockquote><p><strong>Note</strong></p><p>Available in
<a class=link href="index.html#syntax"><code>docker/dockerfile-upstream:master-labs</code></a>.
Will be included in <code>docker/dockerfile:1.6-labs</code>.</p></blockquote><div class="group relative"><button x-data="{ code: 'Q09QWSBbLS1wYXJlbnRzWz08Ym9vbGVhbj5dXSA8c3JjPi4uLiA8ZGVzdD4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>COPY</span> <span class=o>[</span>--parents<span class=o>[=</span>&lt;boolean&gt;<span class=o>]]</span> &lt;src&gt;... &lt;dest&gt;</span></span></code></pre></div></div></div><p>The <code>--parents</code> flag preserves parent directories for <code>src</code> entries. This flag defaults to <code>false</code>.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGUtdXBzdHJlYW06bWFzdGVyLWxhYnMKRlJPTSBzY3JhdGNoCgpDT1BZIC4veC9hLnR4dCAuL3kvYS50eHQgL25vX3BhcmVudHMvCkNPUFkgLS1wYXJlbnRzIC4veC9hLnR4dCAuL3kvYS50eHQgL3BhcmVudHMvCgojIC9ub19wYXJlbnRzL2EudHh0CiMgL3BhcmVudHMveC9hLnR4dAojIC9wYXJlbnRzL3kvYS50eHQ=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile-upstream:master-labs</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> scratch</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> ./x/a.txt ./y/a.txt /no_parents/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> --parents ./x/a.txt ./y/a.txt /parents/<span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /no_parents/a.txt</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/x/a.txt</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># /parents/y/a.txt</span></span></span></code></pre></div></div></div><p>This behavior is analogous to the
<a class=link href=https://www.man7.org/linux/man-pages/man1/cp.1.html target=_blank rel=noopener>Linux <code>cp</code> utility's<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
<code>--parents</code> flag.</p><p>Note that, without the <code>--parents</code> flag specified, any filename collision will
fail the Linux <code>cp</code> operation with an explicit error message
(<code>cp: will not overwrite just-created './x/a.txt' with './y/a.txt'</code>), where the
Buildkit will silently overwrite the target file at the destination.</p><p>While it is possible to preserve the directory structure for <code>COPY</code>
instructions consisting of only one <code>src</code> entry, usually it is more beneficial
to keep the layer count in the resulting image as low as possible. Therefore,
with the <code>--parents</code> flag, the Buildkit is capable of packing multiple
<code>COPY</code> instructions together, keeping the directory structure intact.</p><h2 class=scroll-mt-20 id=entrypoint><a class="text-black dark:text-white no-underline hover:underline" href="index.html#entrypoint">ENTRYPOINT</a></h2><p>An <code>ENTRYPOINT</code> allows you to configure a container that will run as an executable.</p><p><code>ENTRYPOINT</code> has two possible forms:</p><ul><li><p>The exec form, which is the preferred form:</p><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBbImV4ZWN1dGFibGUiLCAicGFyYW0xIiwgInBhcmFtMiJd', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>&#34;executable&#34;</span><span class=p>,</span> <span class=s2>&#34;param1&#34;</span><span class=p>,</span> <span class=s2>&#34;param2&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div></li><li><p>The shell form:</p><div class="group relative"><button x-data="{ code: 'RU5UUllQT0lOVCBjb21tYW5kIHBhcmFtMSBwYXJhbTI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENTRYPOINT</span> <span class=nb>command</span> param1 param2</span></span></code></pre></div></div></div></li></ul><p>For more information about the different forms, see
<a class=link href="index.html#shell-and-exec-form">Shell and exec form</a>.</p><p>The following command starts a container from the <code>nginx</code> with its default
content, listening on port 80:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pIC10IC0tcm0gLXAgODA6ODAgbmdpbng=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -i -t --rm -p 80:80 nginx
</span></span></code></pre></div></div></div><p>Command line arguments to <code>docker run &lt;image></code> will be appended after all
elements in an exec form <code>ENTRYPOINT</code>, and will override all elements specified
using <code>CMD</code>.</p><p>This allows arguments to be passed to the entry point, i.e., <code>docker run &lt;image> -d</code> will pass the <code>-d</code> argument to the entry point. You can override
the <code>ENTRYPOINT</code> instruction using the <code>docker run --entrypoint</code> flag.</p><p>The shell form of <code>ENTRYPOINT</code> prevents any <code>CMD</code> command line arguments from
being used. It also starts your <code>ENTRYPOINT</code> as a subcommand of <code>/bin/sh -c</code>,
which does not pass signals. This means that the executable will not be the
container's <code>PID 1</code>, and will not receive Unix signals. In this case, your
executable doesn't receive a <code>SIGTERM</code> from <code>docker stop &lt;container></code>.</p><p>Only the last <code>ENTRYPOINT</code> instruction in the Dockerfile will have an effect.</p><h3 class=scroll-mt-20 id=exec-form-entrypoint-example><a class="text-black dark:text-white no-underline hover:underline" href="index.html#exec-form-entrypoint-example">Exec form ENTRYPOINT example</a></h3><p>You can use the exec form of <code>ENTRYPOINT</code> to set fairly stable default commands
and arguments and then use either form of <code>CMD</code> to set additional defaults that
are more likely to be changed.</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCBbInRvcCIsICItYiJdCkNNRCBbIi1jIl0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>&#34;top&#34;</span><span class=p>,</span> <span class=s2>&#34;-b&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> <span class=p>[</span><span class=s2>&#34;-c&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div><p>When you run the container, you can see that <code>top</code> is the only process:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLXJtIC0tbmFtZSB0ZXN0ICB0b3AgLUgKCnRvcCAtIDA4OjI1OjAwIHVwICA3OjI3LCAgMCB1c2VycywgIGxvYWQgYXZlcmFnZTogMC4wMCwgMC4wMSwgMC4wNQpUaHJlYWRzOiAgIDEgdG90YWwsICAgMSBydW5uaW5nLCAgIDAgc2xlZXBpbmcsICAgMCBzdG9wcGVkLCAgIDAgem9tYmllCiVDcHUocyk6ICAwLjEgdXMsICAwLjEgc3ksICAwLjAgbmksIDk5LjcgaWQsICAwLjAgd2EsICAwLjAgaGksICAwLjAgc2ksICAwLjAgc3QKS2lCIE1lbTogICAyMDU2NjY4IHRvdGFsLCAgMTYxNjgzMiB1c2VkLCAgIDQzOTgzNiBmcmVlLCAgICA5OTM1MiBidWZmZXJzCktpQiBTd2FwOiAgMTQ0MTg0MCB0b3RhbCwgICAgICAgIDAgdXNlZCwgIDE0NDE4NDAgZnJlZS4gIDEzMjQ0NDAgY2FjaGVkIE1lbQoKICBQSUQgVVNFUiAgICAgIFBSICBOSSAgICBWSVJUICAgIFJFUyAgICBTSFIgUyAlQ1BVICVNRU0gICAgIFRJTUUrIENPTU1BTkQKICAgIDEgcm9vdCAgICAgIDIwICAgMCAgIDE5NzQ0ICAgMjMzNiAgIDIwODAgUiAgMC4wICAwLjEgICAwOjAwLjA0IHRvcA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --rm --name <span class=nb>test</span>  top -H
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>top - 08:25:00 up  7:27,  0 users,  load average: 0.00, 0.01, 0.05
</span></span></span><span class=line><span class=cl><span class=go>Threads:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
</span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>%</span>Cpu<span class=o>(</span>s<span class=o>)</span>:  0.1 us,  0.1 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
</span></span><span class=line><span class=cl><span class=go>KiB Mem:   2056668 total,  1616832 used,   439836 free,    99352 buffers
</span></span></span><span class=line><span class=cl><span class=go>KiB Swap:  1441840 total,        0 used,  1441840 free.  1324440 cached Mem
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND
</span></span></span><span class=line><span class=cl><span class=go>    1 root      20   0   19744   2336   2080 R  0.0  0.1   0:00.04 top
</span></span></span></code></pre></div></div></div><p>To examine the result further, you can use <code>docker exec</code>:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyBhdXgKClVTRVIgICAgICAgUElEICVDUFUgJU1FTSAgICBWU1ogICBSU1MgVFRZICAgICAgU1RBVCBTVEFSVCAgIFRJTUUgQ09NTUFORApyb290ICAgICAgICAgMSAgMi42ICAwLjEgIDE5NzUyICAyMzUyID8gICAgICAgIFNzKyAgMDg6MjQgICAwOjAwIHRvcCAtYiAtSApyb290ICAgICAgICAgNyAgMC4wICAwLjEgIDE1NTcyICAyMTY0ID8gICAgICAgIFIrICAgMDg6MjUgICAwOjAwIHBzIGF1eA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps aux
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
</span></span></span><span class=line><span class=cl><span class=go>root         1  2.6  0.1  19752  2352 ?        Ss+  08:24   0:00 top -b -H
</span></span></span><span class=line><span class=cl><span class=go>root         7  0.0  0.1  15572  2164 ?        R+   08:25   0:00 ps aux
</span></span></span></code></pre></div></div></div><p>And you can gracefully request <code>top</code> to shut down using <code>docker stop test</code>.</p><p>The following Dockerfile shows using the <code>ENTRYPOINT</code> to run Apache in the
foreground (i.e., as <code>PID 1</code>):</p><div class="group relative"><button x-data="{ code: 'RlJPTSBkZWJpYW46c3RhYmxlClJVTiBhcHQtZ2V0IHVwZGF0ZSAmJiBhcHQtZ2V0IGluc3RhbGwgLXkgLS1mb3JjZS15ZXMgYXBhY2hlMgpFWFBPU0UgODAgNDQzClZPTFVNRSBbIi92YXIvd3d3IiwgIi92YXIvbG9nL2FwYWNoZTIiLCAiL2V0Yy9hcGFjaGUyIl0KRU5UUllQT0lOVCBbIi91c3Ivc2Jpbi9hcGFjaGUyY3RsIiwgIi1EIiwgIkZPUkVHUk9VTkQiXQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> debian:stable</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> apt-get update <span class=o>&amp;&amp;</span> apt-get install -y --force-yes apache2<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>EXPOSE</span><span class=s> 80 443</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>VOLUME</span> <span class=p>[</span><span class=s2>&#34;/var/www&#34;</span><span class=p>,</span> <span class=s2>&#34;/var/log/apache2&#34;</span><span class=p>,</span> <span class=s2>&#34;/etc/apache2&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=p>[</span><span class=s2>&#34;/usr/sbin/apache2ctl&#34;</span><span class=p>,</span> <span class=s2>&#34;-D&#34;</span><span class=p>,</span> <span class=s2>&#34;FOREGROUND&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div><p>If you need to write a starter script for a single executable, you can ensure that
the final executable receives the Unix signals by using <code>exec</code> and <code>gosu</code>
commands:</p><div class="group relative"><button x-data="{ code: 'IyEvdXNyL2Jpbi9lbnYgYmFzaApzZXQgLWUKCmlmIFsgIiQxIiA9ICdwb3N0Z3JlcycgXTsgdGhlbgogICAgY2hvd24gLVIgcG9zdGdyZXMgIiRQR0RBVEEiCgogICAgaWYgWyAteiAiJChscyAtQSAiJFBHREFUQSIpIiBdOyB0aGVuCiAgICAgICAgZ29zdSBwb3N0Z3JlcyBpbml0ZGIKICAgIGZpCgogICAgZXhlYyBnb3N1IHBvc3RncmVzICIkQCIKZmkKCmV4ZWMgIiRAIg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=cp>#!/usr/bin/env bash
</span></span></span><span class=line><span class=cl><span class=cp></span><span class=nb>set</span> -e
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=k>if</span> <span class=o>[</span> <span class=s2>&#34;</span><span class=nv>$1</span><span class=s2>&#34;</span> <span class=o>=</span> <span class=s1>&#39;postgres&#39;</span> <span class=o>]</span><span class=p>;</span> <span class=k>then</span>
</span></span><span class=line><span class=cl>    chown -R postgres <span class=s2>&#34;</span><span class=nv>$PGDATA</span><span class=s2>&#34;</span>
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl>    <span class=k>if</span> <span class=o>[</span> -z <span class=s2>&#34;</span><span class=k>$(</span>ls -A <span class=s2>&#34;</span><span class=nv>$PGDATA</span><span class=s2>&#34;</span><span class=k>)</span><span class=s2>&#34;</span> <span class=o>]</span><span class=p>;</span> <span class=k>then</span>
</span></span><span class=line><span class=cl>        gosu postgres initdb
</span></span><span class=line><span class=cl>    <span class=k>fi</span>
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl>    <span class=nb>exec</span> gosu postgres <span class=s2>&#34;</span><span class=nv>$@</span><span class=s2>&#34;</span>
</span></span><span class=line><span class=cl><span class=k>fi</span>
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=nb>exec</span> <span class=s2>&#34;</span><span class=nv>$@</span><span class=s2>&#34;</span></span></span></code></pre></div></div></div><p>Lastly, if you need to do some extra cleanup (or communicate with other containers)
on shutdown, or are co-ordinating more than one executable, you may need to ensure
that the <code>ENTRYPOINT</code> script receives the Unix signals, passes them on, and then
does some more work:</p><div class="group relative"><button x-data="{ code: 'IyEvYmluL3NoCiMgTm90ZTogSSd2ZSB3cml0dGVuIHRoaXMgdXNpbmcgc2ggc28gaXQgd29ya3MgaW4gdGhlIGJ1c3lib3ggY29udGFpbmVyIHRvbwoKIyBVU0UgdGhlIHRyYXAgaWYgeW91IG5lZWQgdG8gYWxzbyBkbyBtYW51YWwgY2xlYW51cCBhZnRlciB0aGUgc2VydmljZSBpcyBzdG9wcGVkLAojICAgICBvciBuZWVkIHRvIHN0YXJ0IG11bHRpcGxlIHNlcnZpY2VzIGluIHRoZSBvbmUgY29udGFpbmVyCnRyYXAgImVjaG8gVFJBUGVkIHNpZ25hbCIgSFVQIElOVCBRVUlUIFRFUk0KCiMgc3RhcnQgc2VydmljZSBpbiBiYWNrZ3JvdW5kIGhlcmUKL3Vzci9zYmluL2FwYWNoZWN0bCBzdGFydAoKZWNobyAiW2hpdCBlbnRlciBrZXkgdG8gZXhpdF0gb3IgcnVuICdkb2NrZXIgc3RvcCA8Y29udGFpbmVyPiciCnJlYWQKCiMgc3RvcCBzZXJ2aWNlIGFuZCBjbGVhbiB1cCBoZXJlCmVjaG8gInN0b3BwaW5nIGFwYWNoZSIKL3Vzci9zYmluL2FwYWNoZWN0bCBzdG9wCgplY2hvICJleGl0ZWQgJDAi', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-bash data-lang=bash><span class=line><span class=cl><span class=cp>#!/bin/sh
</span></span></span><span class=line><span class=cl><span class=cp></span><span class=c1># Note: I&#39;ve written this using sh so it works in the busybox container too</span>
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=c1># USE the trap if you need to also do manual cleanup after the service is stopped,</span>
</span></span><span class=line><span class=cl><span class=c1>#     or need to start multiple services in the one container</span>
</span></span><span class=line><span class=cl><span class=nb>trap</span> <span class=s2>&#34;echo TRAPed signal&#34;</span> HUP INT QUIT TERM
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=c1># start service in background here</span>
</span></span><span class=line><span class=cl>/usr/sbin/apachectl start
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>&#34;[hit enter key to exit] or run &#39;docker stop &lt;container&gt;&#39;&#34;</span>
</span></span><span class=line><span class=cl><span class=nb>read</span>
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=c1># stop service and clean up here</span>
</span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>&#34;stopping apache&#34;</span>
</span></span><span class=line><span class=cl>/usr/sbin/apachectl stop
</span></span><span class=line><span class=cl>
</span></span><span class=line><span class=cl><span class=nb>echo</span> <span class=s2>&#34;exited </span><span class=nv>$0</span><span class=s2>&#34;</span></span></span></code></pre></div></div></div><p>If you run this image with <code>docker run -it --rm -p 80:80 --name test apache</code>,
you can then examine the container's processes with <code>docker exec</code>, or <code>docker top</code>,
and then ask the script to stop Apache:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyBhdXgKClVTRVIgICAgICAgUElEICVDUFUgJU1FTSAgICBWU1ogICBSU1MgVFRZICAgICAgU1RBVCBTVEFSVCAgIFRJTUUgQ09NTUFORApyb290ICAgICAgICAgMSAgMC4xICAwLjAgICA0NDQ4ICAgNjkyID8gICAgICAgIFNzKyAgMDA6NDIgICAwOjAwIC9iaW4vc2ggL3J1bi5zaCAxMjMgY21kIGNtZDIKcm9vdCAgICAgICAgMTkgIDAuMCAgMC4yICA3MTMwNCAgNDQ0MCA/ICAgICAgICBTcyAgIDAwOjQyICAgMDowMCAvdXNyL3NiaW4vYXBhY2hlMiAtayBzdGFydAp3d3ctZGF0YSAgICAyMCAgMC4yICAwLjIgMzYwNDY4ICA2MDA0ID8gICAgICAgIFNsICAgMDA6NDIgICAwOjAwIC91c3Ivc2Jpbi9hcGFjaGUyIC1rIHN0YXJ0Cnd3dy1kYXRhICAgIDIxICAwLjIgIDAuMiAzNjA0NjggIDYwMDAgPyAgICAgICAgU2wgICAwMDo0MiAgIDA6MDAgL3Vzci9zYmluL2FwYWNoZTIgLWsgc3RhcnQKcm9vdCAgICAgICAgODEgIDAuMCAgMC4xICAxNTU3MiAgMjE0MCA/ICAgICAgICBSKyAgIDAwOjQ0ICAgMDowMCBwcyBhdXgKCiQgZG9ja2VyIHRvcCB0ZXN0CgpQSUQgICAgICAgICAgICAgICAgIFVTRVIgICAgICAgICAgICAgICAgQ09NTUFORAoxMDAzNSAgICAgICAgICAgICAgIHJvb3QgICAgICAgICAgICAgICAge3J1bi5zaH0gL2Jpbi9zaCAvcnVuLnNoIDEyMyBjbWQgY21kMgoxMDA1NCAgICAgICAgICAgICAgIHJvb3QgICAgICAgICAgICAgICAgL3Vzci9zYmluL2FwYWNoZTIgLWsgc3RhcnQKMTAwNTUgICAgICAgICAgICAgICAzMyAgICAgICAgICAgICAgICAgIC91c3Ivc2Jpbi9hcGFjaGUyIC1rIHN0YXJ0CjEwMDU2ICAgICAgICAgICAgICAgMzMgICAgICAgICAgICAgICAgICAvdXNyL3NiaW4vYXBhY2hlMiAtayBzdGFydAoKJCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAwLjI3cwp1c2VyCTBtIDAuMDNzCnN5cwkwbSAwLjAzcw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps aux
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
</span></span></span><span class=line><span class=cl><span class=go>root         1  0.1  0.0   4448   692 ?        Ss+  00:42   0:00 /bin/sh /run.sh 123 cmd cmd2
</span></span></span><span class=line><span class=cl><span class=go>root        19  0.0  0.2  71304  4440 ?        Ss   00:42   0:00 /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go>www-data    20  0.2  0.2 360468  6004 ?        Sl   00:42   0:00 /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go>www-data    21  0.2  0.2 360468  6000 ?        Sl   00:42   0:00 /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go>root        81  0.0  0.1  15572  2140 ?        R+   00:44   0:00 ps aux
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> docker top <span class=nb>test</span>
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>PID                 USER                COMMAND
</span></span></span><span class=line><span class=cl><span class=go>10035               root                {run.sh} /bin/sh /run.sh 123 cmd cmd2
</span></span></span><span class=line><span class=cl><span class=go>10054               root                /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go>10055               33                  /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go>10056               33                  /usr/sbin/apache2 -k start
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span>
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test
</span></span></span><span class=line><span class=cl><span class=go>real	0m 0.27s
</span></span></span><span class=line><span class=cl><span class=go>user	0m 0.03s
</span></span></span><span class=line><span class=cl><span class=go>sys	0m 0.03s
</span></span></span></code></pre></div></div></div><blockquote><p><strong>Note</strong></p><p>You can override the <code>ENTRYPOINT</code> setting using <code>--entrypoint</code>,
but this can only set the binary to exec (no <code>sh -c</code> will be used).</p></blockquote><h3 class=scroll-mt-20 id=shell-form-entrypoint-example><a class="text-black dark:text-white no-underline hover:underline" href="index.html#shell-form-entrypoint-example">Shell form ENTRYPOINT example</a></h3><p>You can specify a plain string for the <code>ENTRYPOINT</code> and it will execute in <code>/bin/sh -c</code>.
This form will use shell processing to substitute shell environment variables,
and will ignore any <code>CMD</code> or <code>docker run</code> command line arguments.
To ensure that <code>docker stop</code> will signal any long running <code>ENTRYPOINT</code> executable
correctly, you need to remember to start it with <code>exec</code>:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCBleGVjIHRvcCAtYg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> <span class=nb>exec</span> top -b</span></span></code></pre></div></div></div><p>When you run this image, you'll see the single <code>PID 1</code> process:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLXJtIC0tbmFtZSB0ZXN0IHRvcAoKTWVtOiAxNzA0NTIwSyB1c2VkLCAzNTIxNDhLIGZyZWUsIDBLIHNocmQsIDBLIGJ1ZmYsIDE0MDM2ODEyMTE2Nzg3M0sgY2FjaGVkCkNQVTogICA1JSB1c3IgICAwJSBzeXMgICAwJSBuaWMgIDk0JSBpZGxlICAgMCUgaW8gICAwJSBpcnEgICAwJSBzaXJxCkxvYWQgYXZlcmFnZTogMC4wOCAwLjAzIDAuMDUgMi85OCA2CiAgUElEICBQUElEIFVTRVIgICAgIFNUQVQgICBWU1ogJVZTWiAlQ1BVIENPTU1BTkQKICAgIDEgICAgIDAgcm9vdCAgICAgUiAgICAgMzE2NCAgIDAlICAgMCUgdG9wIC1i', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --rm --name <span class=nb>test</span> top
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Mem: 1704520K used, 352148K free, 0K shrd, 0K buff, 140368121167873K cached
</span></span></span><span class=line><span class=cl><span class=go>CPU:   5% usr   0% sys   0% nic  94% idle   0% io   0% irq   0% sirq
</span></span></span><span class=line><span class=cl><span class=go>Load average: 0.08 0.03 0.05 2/98 6
</span></span></span><span class=line><span class=cl><span class=go>  PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
</span></span></span><span class=line><span class=cl><span class=go>    1     0 root     R     3164   0%   0% top -b
</span></span></span></code></pre></div></div></div><p>Which exits cleanly on <code>docker stop</code>:</p><div class="group relative"><button x-data="{ code: 'JCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAwLjIwcwp1c2VyCTBtIDAuMDJzCnN5cwkwbSAwLjA0cw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span>
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test
</span></span></span><span class=line><span class=cl><span class=go>real	0m 0.20s
</span></span></span><span class=line><span class=cl><span class=go>user	0m 0.02s
</span></span></span><span class=line><span class=cl><span class=go>sys	0m 0.04s
</span></span></span></code></pre></div></div></div><p>If you forget to add <code>exec</code> to the beginning of your <code>ENTRYPOINT</code>:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKRU5UUllQT0lOVCB0b3AgLWIKQ01EIC0tIC0taWdub3JlZC1wYXJhbTE=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> top -b<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>CMD</span> -- --ignored-param1</span></span></code></pre></div></div></div><p>You can then run it (giving it a name for the next step):</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgcnVuIC1pdCAtLW5hbWUgdGVzdCB0b3AgLS1pZ25vcmVkLXBhcmFtMgoKdG9wIC0gMTM6NTg6MjQgdXAgMTcgbWluLCAgMCB1c2VycywgIGxvYWQgYXZlcmFnZTogMC4wMCwgMC4wMCwgMC4wMApUYXNrczogICAyIHRvdGFsLCAgIDEgcnVubmluZywgICAxIHNsZWVwaW5nLCAgIDAgc3RvcHBlZCwgICAwIHpvbWJpZQolQ3B1KHMpOiAxNi43IHVzLCAzMy4zIHN5LCAgMC4wIG5pLCA1MC4wIGlkLCAgMC4wIHdhLCAgMC4wIGhpLCAgMC4wIHNpLCAgMC4wIHN0Ck1pQiBNZW0gOiAgIDE5OTAuOCB0b3RhbCwgICAxMzU0LjYgZnJlZSwgICAgMjMxLjQgdXNlZCwgICAgNDA0LjcgYnVmZi9jYWNoZQpNaUIgU3dhcDogICAxMDI0LjAgdG90YWwsICAgMTAyNC4wIGZyZWUsICAgICAgMC4wIHVzZWQuICAgMTYzOS44IGF2YWlsIE1lbQoKICBQSUQgVVNFUiAgICAgIFBSICBOSSAgICBWSVJUICAgIFJFUyAgICBTSFIgUyAgJUNQVSAgJU1FTSAgICAgVElNRSsgQ09NTUFORAogICAgMSByb290ICAgICAgMjAgICAwICAgIDI2MTIgICAgNjA0ICAgIDUzNiBTICAgMC4wICAgMC4wICAgMDowMC4wMiBzaAogICAgNiByb290ICAgICAgMjAgICAwICAgIDU5NTYgICAzMTg4ICAgMjc2OCBSICAgMC4wICAgMC4yICAgMDowMC4wMCB0b3A=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker run -it --name <span class=nb>test</span> top --ignored-param2
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>top - 13:58:24 up 17 min,  0 users,  load average: 0.00, 0.00, 0.00
</span></span></span><span class=line><span class=cl><span class=go>Tasks:   2 total,   1 running,   1 sleeping,   0 stopped,   0 zombie
</span></span></span><span class=line><span class=cl><span class=go></span><span class=gp>%</span>Cpu<span class=o>(</span>s<span class=o>)</span>: 16.7 us, 33.3 sy,  0.0 ni, 50.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
</span></span><span class=line><span class=cl><span class=go>MiB Mem :   1990.8 total,   1354.6 free,    231.4 used,    404.7 buff/cache
</span></span></span><span class=line><span class=cl><span class=go>MiB Swap:   1024.0 total,   1024.0 free,      0.0 used.   1639.8 avail Mem
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
</span></span></span><span class=line><span class=cl><span class=go>    1 root      20   0    2612    604    536 S   0.0   0.0   0:00.02 sh
</span></span></span><span class=line><span class=cl><span class=go>    6 root      20   0    5956   3188   2768 R   0.0   0.2   0:00.00 top
</span></span></span></code></pre></div></div></div><p>You can see from the output of <code>top</code> that the specified <code>ENTRYPOINT</code> is not <code>PID 1</code>.</p><p>If you then run <code>docker stop test</code>, the container will not exit cleanly - the
<code>stop</code> command will be forced to send a <code>SIGKILL</code> after the timeout:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgZXhlYyAtaXQgdGVzdCBwcyB3YXV4CgpVU0VSICAgICAgIFBJRCAlQ1BVICVNRU0gICAgVlNaICAgUlNTIFRUWSAgICAgIFNUQVQgU1RBUlQgICBUSU1FIENPTU1BTkQKcm9vdCAgICAgICAgIDEgIDAuNCAgMC4wICAgMjYxMiAgIDYwNCBwdHMvMCAgICBTcysgIDEzOjU4ICAgMDowMCAvYmluL3NoIC1jIHRvcCAtYiAtLWlnbm9yZWQtcGFyYW0yCnJvb3QgICAgICAgICA2ICAwLjAgIDAuMSAgIDU5NTYgIDMxODggcHRzLzAgICAgUysgICAxMzo1OCAgIDA6MDAgdG9wIC1iCnJvb3QgICAgICAgICA3ICAwLjAgIDAuMSAgIDU4ODQgIDI4MTYgcHRzLzEgICAgUnMrICAxMzo1OCAgIDA6MDAgcHMgd2F1eAoKJCAvdXNyL2Jpbi90aW1lIGRvY2tlciBzdG9wIHRlc3QKCnRlc3QKcmVhbAkwbSAxMC4xOXMKdXNlcgkwbSAwLjA0cwpzeXMJMG0gMC4wM3M=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker <span class=nb>exec</span> -it <span class=nb>test</span> ps waux
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
</span></span></span><span class=line><span class=cl><span class=go>root         1  0.4  0.0   2612   604 pts/0    Ss+  13:58   0:00 /bin/sh -c top -b --ignored-param2
</span></span></span><span class=line><span class=cl><span class=go>root         6  0.0  0.1   5956  3188 pts/0    S+   13:58   0:00 top -b
</span></span></span><span class=line><span class=cl><span class=go>root         7  0.0  0.1   5884  2816 pts/1    Rs+  13:58   0:00 ps waux
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=gp>$</span> /usr/bin/time docker stop <span class=nb>test</span>
</span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>test
</span></span></span><span class=line><span class=cl><span class=go>real	0m 10.19s
</span></span></span><span class=line><span class=cl><span class=go>user	0m 0.04s
</span></span></span><span class=line><span class=cl><span class=go>sys	0m 0.03s
</span></span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=understand-how-cmd-and-entrypoint-interact><a class="text-black dark:text-white no-underline hover:underline" href="index.html#understand-how-cmd-and-entrypoint-interact">Understand how CMD and ENTRYPOINT interact</a></h3><p>Both <code>CMD</code> and <code>ENTRYPOINT</code> instructions define what command gets executed when running a container.
There are few rules that describe their co-operation.</p><ol><li><p>Dockerfile should specify at least one of <code>CMD</code> or <code>ENTRYPOINT</code> commands.</p></li><li><p><code>ENTRYPOINT</code> should be defined when using the container as an executable.</p></li><li><p><code>CMD</code> should be used as a way of defining default arguments for an <code>ENTRYPOINT</code> command
or for executing an ad-hoc command in a container.</p></li><li><p><code>CMD</code> will be overridden when running the container with alternative arguments.</p></li></ol><p>The table below shows what command is executed for different <code>ENTRYPOINT</code> / <code>CMD</code> combinations:</p><table><thead><tr><th style=text-align:left></th><th style=text-align:left>No ENTRYPOINT</th><th style=text-align:left>ENTRYPOINT exec_entry p1_entry</th><th style=text-align:left>ENTRYPOINT ["exec_entry", "p1_entry"]</th></tr></thead><tbody><tr><td style=text-align:left><strong>No CMD</strong></td><td style=text-align:left>error, not allowed</td><td style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td style=text-align:left>exec_entry p1_entry</td></tr><tr><td style=text-align:left><strong>CMD ["exec_cmd", "p1_cmd"]</strong></td><td style=text-align:left>exec_cmd p1_cmd</td><td style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td style=text-align:left>exec_entry p1_entry exec_cmd p1_cmd</td></tr><tr><td style=text-align:left><strong>CMD exec_cmd p1_cmd</strong></td><td style=text-align:left>/bin/sh -c exec_cmd p1_cmd</td><td style=text-align:left>/bin/sh -c exec_entry p1_entry</td><td style=text-align:left>exec_entry p1_entry /bin/sh -c exec_cmd p1_cmd</td></tr></tbody></table><blockquote><p><strong>Note</strong></p><p>If <code>CMD</code> is defined from the base image, setting <code>ENTRYPOINT</code> will
reset <code>CMD</code> to an empty value. In this scenario, <code>CMD</code> must be defined in the
current image to have a value.</p></blockquote><h2 class=scroll-mt-20 id=volume><a class="text-black dark:text-white no-underline hover:underline" href="index.html#volume">VOLUME</a></h2><div class="group relative"><button x-data="{ code: 'Vk9MVU1FIFsiL2RhdGEiXQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>VOLUME</span> <span class=p>[</span><span class=s2>&#34;/data&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div><p>The <code>VOLUME</code> instruction creates a mount point with the specified name
and marks it as holding externally mounted volumes from native host or other
containers. The value can be a JSON array, <code>VOLUME ["/var/log/"]</code>, or a plain
string with multiple arguments, such as <code>VOLUME /var/log</code> or <code>VOLUME /var/log /var/db</code>. For more information/examples and mounting instructions via the
Docker client, refer to
<a class=link href="../../../storage/volumes/index.html" target=_blank rel=noopener><em>Share Directories via Volumes</em><span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
documentation.</p><p>The <code>docker run</code> command initializes the newly created volume with any data
that exists at the specified location within the base image. For example,
consider the following Dockerfile snippet:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKUlVOIG1rZGlyIC9teXZvbApSVU4gZWNobyAiaGVsbG8gd29ybGQiID4gL215dm9sL2dyZWV0aW5nClZPTFVNRSAvbXl2b2w=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> mkdir /myvol<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>&#34;hello world&#34;</span> &gt; /myvol/greeting<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>VOLUME</span><span class=s> /myvol</span></span></span></code></pre></div></div></div><p>This Dockerfile results in an image that causes <code>docker run</code> to
create a new mount point at <code>/myvol</code> and copy the <code>greeting</code> file
into the newly created volume.</p><h3 class=scroll-mt-20 id=notes-about-specifying-volumes><a class="text-black dark:text-white no-underline hover:underline" href="index.html#notes-about-specifying-volumes">Notes about specifying volumes</a></h3><p>Keep the following things in mind about volumes in the Dockerfile.</p><ul><li><p><strong>Volumes on Windows-based containers</strong>: When using Windows-based containers,
the destination of a volume inside the container must be one of:</p><ul><li>a non-existing or empty directory</li><li>a drive other than <code>C:</code></li></ul></li><li><p><strong>Changing the volume from within the Dockerfile</strong>: If any build steps change the
data within the volume after it has been declared, those changes will be discarded.</p></li><li><p><strong>JSON formatting</strong>: The list is parsed as a JSON array.
You must enclose words with double quotes (<code>"</code>) rather than single quotes (<code>'</code>).</p></li><li><p><strong>The host directory is declared at container run-time</strong>: The host directory
(the mountpoint) is, by its nature, host-dependent. This is to preserve image
portability, since a given host directory can't be guaranteed to be available
on all hosts. For this reason, you can't mount a host directory from
within the Dockerfile. The <code>VOLUME</code> instruction does not support specifying a <code>host-dir</code>
parameter. You must specify the mountpoint when you create or run the container.</p></li></ul><h2 class=scroll-mt-20 id=user><a class="text-black dark:text-white no-underline hover:underline" href="index.html#user">USER</a></h2><div class="group relative"><button x-data="{ code: 'VVNFUiA8dXNlcj5bOjxncm91cD5d', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>USER</span><span class=s> &lt;user&gt;[:&lt;group&gt;]</span></span></span></code></pre></div></div></div><p>or</p><div class="group relative"><button x-data="{ code: 'VVNFUiA8VUlEPls6PEdJRD5d', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>USER</span><span class=s> &lt;UID&gt;[:&lt;GID&gt;]</span></span></span></code></pre></div></div></div><p>The <code>USER</code> instruction sets the user name (or UID) and optionally the user
group (or GID) to use as the default user and group for the remainder of the
current stage. The specified user is used for <code>RUN</code> instructions and at
runtime, runs the relevant <code>ENTRYPOINT</code> and <code>CMD</code> commands.</p><blockquote><p>Note that when specifying a group for the user, the user will have <em>only</em> the
specified group membership. Any other configured group memberships will be ignored.</p></blockquote><blockquote class=warning><p><strong>Warning</strong></p><p>When the user doesn't have a primary group then the image (or the next
instructions) will be run with the <code>root</code> group.</p><p>On Windows, the user must be created first if it's not a built-in account.
This can be done with the <code>net user</code> command called as part of a Dockerfile.</p></blockquote><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvd2luZG93c3NlcnZlcmNvcmUKIyBDcmVhdGUgV2luZG93cyB1c2VyIGluIHRoZSBjb250YWluZXIKUlVOIG5ldCB1c2VyIC9hZGQgcGF0cmljawojIFNldCBpdCBmb3Igc3Vic2VxdWVudCBjb21tYW5kcwpVU0VSIHBhdHJpY2s=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/windowsservercore</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Create Windows user in the container</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> net user /add patrick<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Set it for subsequent commands</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> patrick</span></span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=workdir><a class="text-black dark:text-white no-underline hover:underline" href="index.html#workdir">WORKDIR</a></h2><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvcGF0aC90by93b3JrZGly', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /path/to/workdir</span></span></span></code></pre></div></div></div><p>The <code>WORKDIR</code> instruction sets the working directory for any <code>RUN</code>, <code>CMD</code>,
<code>ENTRYPOINT</code>, <code>COPY</code> and <code>ADD</code> instructions that follow it in the Dockerfile.
If the <code>WORKDIR</code> doesn't exist, it will be created even if it's not used in any
subsequent Dockerfile instruction.</p><p>The <code>WORKDIR</code> instruction can be used multiple times in a Dockerfile. If a
relative path is provided, it will be relative to the path of the previous
<code>WORKDIR</code> instruction. For example:</p><div class="group relative"><button x-data="{ code: 'V09SS0RJUiAvYQpXT1JLRElSIGIKV09SS0RJUiBjClJVTiBwd2Q=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>WORKDIR</span><span class=s> /a</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> b</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> c</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pwd</span></span></code></pre></div></div></div><p>The output of the final <code>pwd</code> command in this Dockerfile would be <code>/a/b/c</code>.</p><p>The <code>WORKDIR</code> instruction can resolve environment variables previously set using
<code>ENV</code>. You can only use environment variables explicitly set in the Dockerfile.
For example:</p><div class="group relative"><button x-data="{ code: 'RU5WIERJUlBBVEg9L3BhdGgKV09SS0RJUiAkRElSUEFUSC8kRElSTkFNRQpSVU4gcHdk', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ENV</span> <span class=nv>DIRPATH</span><span class=o>=</span>/path<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> $DIRPATH/$DIRNAME</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> pwd</span></span></code></pre></div></div></div><p>The output of the final <code>pwd</code> command in this Dockerfile would be
<code>/path/$DIRNAME</code></p><p>If not specified, the default working directory is <code>/</code>. In practice, if you aren't building a Dockerfile from scratch (<code>FROM scratch</code>),
the <code>WORKDIR</code> may likely be set by the base image you're using.</p><p>Therefore, to avoid unintended operations in unknown directories, it's best practice to set your <code>WORKDIR</code> explicitly.</p><h2 class=scroll-mt-20 id=arg><a class="text-black dark:text-white no-underline hover:underline" href="index.html#arg">ARG</a></h2><div class="group relative"><button x-data="{ code: 'QVJHIDxuYW1lPls9PGRlZmF1bHQgdmFsdWU+XQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ARG</span> &lt;name&gt;<span class=o>[=</span>&lt;default value&gt;<span class=o>]</span></span></span></code></pre></div></div></div><p>The <code>ARG</code> instruction defines a variable that users can pass at build-time to
the builder with the <code>docker build</code> command using the <code>--build-arg &lt;varname>=&lt;value></code>
flag.</p><blockquote class=warning><p><strong>Warning</strong></p><p>It isn't recommended to use build arguments for passing secrets such as
user credentials, API tokens, etc. Build arguments are visible in the
<code>docker history</code> command and in <code>max</code> mode provenance attestations,
which are attached to the image by default if you use the Buildx GitHub Actions
and your GitHub repository is public.</p><p>Refer to the
<a class=link href="index.html#run---mounttypesecret"><code>RUN --mount=type=secret</code></a> section to
learn about secure ways to use secrets when building images.</p></blockquote><p>If you specify a build argument that wasn't defined in the Dockerfile,
the build outputs a warning.</p><div class="group relative"><button x-data="{ code: 'W1dhcm5pbmddIE9uZSBvciBtb3JlIGJ1aWxkLWFyZ3MgW2Zvb10gd2VyZSBub3QgY29uc3VtZWQu', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>[Warning] One or more build-args [foo] were not consumed.
</span></span></span></code></pre></div></div></div><p>A Dockerfile may include one or more <code>ARG</code> instructions. For example,
the following is a valid Dockerfile:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkFSRyB1c2VyMQpBUkcgYnVpbGRubwojIC4uLg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> user1<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> buildno<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ...</span></span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=default-values><a class="text-black dark:text-white no-underline hover:underline" href="index.html#default-values">Default values</a></h3><p>An <code>ARG</code> instruction can optionally include a default value:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkFSRyB1c2VyMT1zb21ldXNlcgpBUkcgYnVpbGRubz0xCiMgLi4u', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>user1</span><span class=o>=</span>someuser
</span></span><span class=line><span class=cl><span class=k>ARG</span> <span class=nv>buildno</span><span class=o>=</span><span class=m>1</span>
</span></span><span class=line><span class=cl><span class=c># ...</span></span></span></code></pre></div></div></div><p>If an <code>ARG</code> instruction has a default value and if there is no value passed
at build-time, the builder uses the default.</p><h3 class=scroll-mt-20 id=scope><a class="text-black dark:text-white no-underline hover:underline" href="index.html#scope">Scope</a></h3><p>An <code>ARG</code> variable definition comes into effect from the line on which it is
defined in the Dockerfile not from the argument's use on the command-line or
elsewhere. For example, consider this Dockerfile:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94ClVTRVIgJHt1c2VybmFtZTotc29tZV91c2VyfQpBUkcgdXNlcm5hbWUKVVNFUiAkdXNlcm5hbWUKIyAuLi4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> ${username:-some_user}</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> username<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>USER</span><span class=s> $username</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># ...</span></span></span></code></pre></div></div></div><p>A user builds this file by calling:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgdXNlcm5hbWU9d2hhdF91c2VyIC4=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>username</span><span class=o>=</span>what_user .
</span></span></code></pre></div></div></div><p>The <code>USER</code> at line 2 evaluates to <code>some_user</code> as the <code>username</code> variable is defined on the
subsequent line 3. The <code>USER</code> at line 4 evaluates to <code>what_user</code>, as the <code>username</code> argument is
defined and the <code>what_user</code> value was passed on the command line. Prior to its definition by an
<code>ARG</code> instruction, any use of a variable results in an empty string.</p><p>An <code>ARG</code> instruction goes out of scope at the end of the build
stage where it was defined. To use an argument in multiple stages, each stage must
include the <code>ARG</code> instruction.</p><div class="group relative"><button x-data="{ code: 'RlJPTSBidXN5Ym94CkFSRyBTRVRUSU5HUwpSVU4gLi9ydW4vc2V0dXAgJFNFVFRJTkdTCgpGUk9NIGJ1c3lib3gKQVJHIFNFVFRJTkdTClJVTiAuL3J1bi9vdGhlciAkU0VUVElOR1M=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> SETTINGS<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> ./run/setup <span class=nv>$SETTINGS</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> busybox</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> SETTINGS<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> ./run/other <span class=nv>$SETTINGS</span></span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=using-arg-variables><a class="text-black dark:text-white no-underline hover:underline" href="index.html#using-arg-variables">Using ARG variables</a></h3><p>You can use an <code>ARG</code> or an <code>ENV</code> instruction to specify variables that are
available to the <code>RUN</code> instruction. Environment variables defined using the
<code>ENV</code> instruction always override an <code>ARG</code> instruction of the same name. Consider
this Dockerfile with an <code>ENV</code> and <code>ARG</code> instruction.</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPXYxLjAuMApSVU4gZWNobyAkQ09OVF9JTUdfVkVS', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span>v1.0.0<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div><p>Then, assume this image is built with this command:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgQ09OVF9JTUdfVkVSPXYyLjAuMSAu', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>CONT_IMG_VER</span><span class=o>=</span>v2.0.1 .
</span></span></code></pre></div></div></div><p>In this case, the <code>RUN</code> instruction uses <code>v1.0.0</code> instead of the <code>ARG</code> setting
passed by the user:<code>v2.0.1</code> This behavior is similar to a shell
script where a locally scoped variable overrides the variables passed as
arguments or inherited from environment, from its point of definition.</p><p>Using the example above but a different <code>ENV</code> specification you can create more
useful interactions between <code>ARG</code> and <code>ENV</code> instructions:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPSR7Q09OVF9JTUdfVkVSOi12MS4wLjB9ClJVTiBlY2hvICRDT05UX0lNR19WRVI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span><span class=si>${</span><span class=nv>CONT_IMG_VER</span><span class=k>:-</span><span class=nv>v1</span><span class=p>.0.0</span><span class=si>}</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div><p>Unlike an <code>ARG</code> instruction, <code>ENV</code> values are always persisted in the built
image. Consider a docker build without the <code>--build-arg</code> flag:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build .
</span></span></code></pre></div></div></div><p>Using this Dockerfile example, <code>CONT_IMG_VER</code> is still persisted in the image but
its value would be <code>v1.0.0</code> as it is the default set in line 3 by the <code>ENV</code> instruction.</p><p>The variable expansion technique in this example allows you to pass arguments
from the command line and persist them in the final image by leveraging the
<code>ENV</code> instruction. Variable expansion is only supported for
<a class=link href="index.html#environment-replacement">a limited set of
Dockerfile instructions.</a></p><h3 class=scroll-mt-20 id=predefined-args><a class="text-black dark:text-white no-underline hover:underline" href="index.html#predefined-args">Predefined ARGs</a></h3><p>Docker has a set of predefined <code>ARG</code> variables that you can use without a
corresponding <code>ARG</code> instruction in the Dockerfile.</p><ul><li><code>HTTP_PROXY</code></li><li><code>http_proxy</code></li><li><code>HTTPS_PROXY</code></li><li><code>https_proxy</code></li><li><code>FTP_PROXY</code></li><li><code>ftp_proxy</code></li><li><code>NO_PROXY</code></li><li><code>no_proxy</code></li><li><code>ALL_PROXY</code></li><li><code>all_proxy</code></li></ul><p>To use these, pass them on the command line using the <code>--build-arg</code> flag, for
example:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgSFRUUFNfUFJPWFk9aHR0cHM6Ly9teS1wcm94eS5leGFtcGxlLmNvbSAu', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>HTTPS_PROXY</span><span class=o>=</span>https://my-proxy.example.com .
</span></span></code></pre></div></div></div><p>By default, these pre-defined variables are excluded from the output of
<code>docker history</code>. Excluding them reduces the risk of accidentally leaking
sensitive authentication information in an <code>HTTP_PROXY</code> variable.</p><p>For example, consider building the following Dockerfile using
<code>--build-arg HTTP_PROXY=http://user:pass@proxy.lon.example.com</code></p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKUlVOIGVjaG8gIkhlbGxvIFdvcmxkIg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>&#34;Hello World&#34;</span></span></span></code></pre></div></div></div><p>In this case, the value of the <code>HTTP_PROXY</code> variable is not available in the
<code>docker history</code> and is not cached. If you were to change location, and your
proxy server changed to <code>http://user:pass@proxy.sfo.example.com</code>, a subsequent
build does not result in a cache miss.</p><p>If you need to override this behaviour then you may do so by adding an <code>ARG</code>
statement in the Dockerfile as follows:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIEhUVFBfUFJPWFkKUlVOIGVjaG8gIkhlbGxvIFdvcmxkIg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> HTTP_PROXY<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>&#34;Hello World&#34;</span></span></span></code></pre></div></div></div><p>When building this Dockerfile, the <code>HTTP_PROXY</code> is preserved in the
<code>docker history</code>, and changing its value invalidates the build cache.</p><h3 class=scroll-mt-20 id=automatic-platform-args-in-the-global-scope><a class="text-black dark:text-white no-underline hover:underline" href="index.html#automatic-platform-args-in-the-global-scope">Automatic platform ARGs in the global scope</a></h3><p>This feature is only available when using the
<a class=link href="../../../build/buildkit/index.html" target=_blank rel=noopener>BuildKit<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
backend.</p><p>BuildKit supports a predefined set of <code>ARG</code> variables with information on the platform of
the node performing the build (build platform) and on the platform of the
resulting image (target platform). The target platform can be specified with
the <code>--platform</code> flag on <code>docker build</code>.</p><p>The following <code>ARG</code> variables are set automatically:</p><ul><li><code>TARGETPLATFORM</code> - platform of the build result. Eg <code>linux/amd64</code>, <code>linux/arm/v7</code>, <code>windows/amd64</code>.</li><li><code>TARGETOS</code> - OS component of TARGETPLATFORM</li><li><code>TARGETARCH</code> - architecture component of TARGETPLATFORM</li><li><code>TARGETVARIANT</code> - variant component of TARGETPLATFORM</li><li><code>BUILDPLATFORM</code> - platform of the node performing the build.</li><li><code>BUILDOS</code> - OS component of BUILDPLATFORM</li><li><code>BUILDARCH</code> - architecture component of BUILDPLATFORM</li><li><code>BUILDVARIANT</code> - variant component of BUILDPLATFORM</li></ul><p>These arguments are defined in the global scope so are not automatically
available inside build stages or for your <code>RUN</code> commands. To expose one of
these arguments inside the build stage redefine it without value.</p><p>For example:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBhbHBpbmUKQVJHIFRBUkdFVFBMQVRGT1JNClJVTiBlY2hvICJJJ20gYnVpbGRpbmcgZm9yICRUQVJHRVRQTEFURk9STSI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> TARGETPLATFORM<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=s2>&#34;I&#39;m building for </span><span class=nv>$TARGETPLATFORM</span><span class=s2>&#34;</span></span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=buildkit-built-in-build-args><a class="text-black dark:text-white no-underline hover:underline" href="index.html#buildkit-built-in-build-args">BuildKit built-in build args</a></h3><table><thead><tr><th>Arg</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>BUILDKIT_CACHE_MOUNT_NS</code></td><td>String</td><td>Set optional cache ID namespace.</td></tr><tr><td><code>BUILDKIT_CONTEXT_KEEP_GIT_DIR</code></td><td>Bool</td><td>Trigger Git context to keep the <code>.git</code> directory.</td></tr><tr><td><code>BUILDKIT_INLINE_CACHE</code><sup id=fnref:2><a href="index.html#fn:2" class=footnote-ref role=doc-noteref>2</a></sup></td><td>Bool</td><td>Inline cache metadata to image config or not.</td></tr><tr><td><code>BUILDKIT_MULTI_PLATFORM</code></td><td>Bool</td><td>Opt into deterministic output regardless of multi-platform output or not.</td></tr><tr><td><code>BUILDKIT_SANDBOX_HOSTNAME</code></td><td>String</td><td>Set the hostname (default <code>buildkitsandbox</code>)</td></tr><tr><td><code>BUILDKIT_SYNTAX</code></td><td>String</td><td>Set frontend image</td></tr><tr><td><code>SOURCE_DATE_EPOCH</code></td><td>Int</td><td>Set the Unix timestamp for created image and layers. More info from
<a class=link href=https://reproducible-builds.org/docs/source-date-epoch/ target=_blank rel=noopener>reproducible builds<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>. Supported since Dockerfile 1.5, BuildKit 0.11</td></tr></tbody></table><h4 class=scroll-mt-20 id=example-keep-git-dir><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-keep-git-dir">Example: keep .git dir</a></h4><p>When using a Git context, <code>.git</code> dir is not kept on checkouts. It can be
useful to keep it around if you want to retrieve git information during
your build:</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpXT1JLRElSIC9zcmMKUlVOIC0tbW91bnQ9dGFyZ2V0PS4gXAogIG1ha2UgUkVWSVNJT049JChnaXQgcmV2LXBhcnNlIEhFQUQpIGJ1aWxk', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>WORKDIR</span><span class=s> /src</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> --mount<span class=o>=</span><span class=nv>target</span><span class=o>=</span>. <span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>  make <span class=nv>REVISION</span><span class=o>=</span><span class=k>$(</span>git rev-parse HEAD<span class=k>)</span> build</span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLS1idWlsZC1hcmcgQlVJTERLSVRfQ09OVEVYVF9LRUVQX0dJVF9ESVI9MSBodHRwczovL2dpdGh1Yi5jb20vdXNlci9yZXBvLmdpdCNtYWlu', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build --build-arg <span class=nv>BUILDKIT_CONTEXT_KEEP_GIT_DIR</span><span class=o>=</span><span class=m>1</span> https://github.com/user/repo.git#main
</span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=impact-on-build-caching><a class="text-black dark:text-white no-underline hover:underline" href="index.html#impact-on-build-caching">Impact on build caching</a></h3><p><code>ARG</code> variables are not persisted into the built image as <code>ENV</code> variables are.
However, <code>ARG</code> variables do impact the build cache in similar ways. If a
Dockerfile defines an <code>ARG</code> variable whose value is different from a previous
build, then a "cache miss" occurs upon its first usage, not its definition. In
particular, all <code>RUN</code> instructions following an <code>ARG</code> instruction use the <code>ARG</code>
variable implicitly (as an environment variable), thus can cause a cache miss.
All predefined <code>ARG</code> variables are exempt from caching unless there is a
matching <code>ARG</code> statement in the Dockerfile.</p><p>For example, consider these two Dockerfile:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpSVU4gZWNobyAkQ09OVF9JTUdfVkVS', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpSVU4gZWNobyBoZWxsbw==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div><p>If you specify <code>--build-arg CONT_IMG_VER=&lt;value></code> on the command line, in both
cases, the specification on line 2 doesn't cause a cache miss; line 3 does
cause a cache miss. <code>ARG CONT_IMG_VER</code> causes the <code>RUN</code> line to be identified
as the same as running <code>CONT_IMG_VER=&lt;value> echo hello</code>, so if the <code>&lt;value></code>
changes, you get a cache miss.</p><p>Consider another example under the same command line:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPSRDT05UX0lNR19WRVIKUlVOIGVjaG8gJENPTlRfSU1HX1ZFUg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span><span class=nv>$CONT_IMG_VER</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div><p>In this example, the cache miss occurs on line 3. The miss happens because
the variable's value in the <code>ENV</code> references the <code>ARG</code> variable and that
variable is changed through the command line. In this example, the <code>ENV</code>
command causes the image to include the value.</p><p>If an <code>ENV</code> instruction overrides an <code>ARG</code> instruction of the same name, like
this Dockerfile:</p><div class="group relative"><button x-data="{ code: 'RlJPTSB1YnVudHUKQVJHIENPTlRfSU1HX1ZFUgpFTlYgQ09OVF9JTUdfVkVSPWhlbGxvClJVTiBlY2hvICRDT05UX0lNR19WRVI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> ubuntu</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> CONT_IMG_VER<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENV</span> <span class=nv>CONT_IMG_VER</span><span class=o>=</span>hello
</span></span><span class=line><span class=cl><span class=k>RUN</span> <span class=nb>echo</span> <span class=nv>$CONT_IMG_VER</span></span></span></code></pre></div></div></div><p>Line 3 doesn't cause a cache miss because the value of <code>CONT_IMG_VER</code> is a
constant (<code>hello</code>). As a result, the environment variables and values used on
the <code>RUN</code> (line 4) doesn't change between builds.</p><h2 class=scroll-mt-20 id=onbuild><a class="text-black dark:text-white no-underline hover:underline" href="index.html#onbuild">ONBUILD</a></h2><div class="group relative"><button x-data="{ code: 'T05CVUlMRCA8SU5TVFJVQ1RJT04+', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ONBUILD</span> &lt;INSTRUCTION&gt;</span></span></code></pre></div></div></div><p>The <code>ONBUILD</code> instruction adds to the image a trigger instruction to
be executed at a later time, when the image is used as the base for
another build. The trigger will be executed in the context of the
downstream build, as if it had been inserted immediately after the
<code>FROM</code> instruction in the downstream Dockerfile.</p><p>Any build instruction can be registered as a trigger.</p><p>This is useful if you are building an image which will be used as a base
to build other images, for example an application build environment or a
daemon which may be customized with user-specific configuration.</p><p>For example, if your image is a reusable Python application builder, it
will require application source code to be added in a particular
directory, and it might require a build script to be called after
that. You can't just call <code>ADD</code> and <code>RUN</code> now, because you don't yet
have access to the application source code, and it will be different for
each application build. You could simply provide application developers
with a boilerplate Dockerfile to copy-paste into their application, but
that's inefficient, error-prone and difficult to update because it
mixes with application-specific code.</p><p>The solution is to use <code>ONBUILD</code> to register advance instructions to
run later, during the next build stage.</p><p>Here's how it works:</p><ol><li>When it encounters an <code>ONBUILD</code> instruction, the builder adds a
trigger to the metadata of the image being built. The instruction
doesn't otherwise affect the current build.</li><li>At the end of the build, a list of all triggers is stored in the
image manifest, under the key <code>OnBuild</code>. They can be inspected with
the <code>docker inspect</code> command.</li><li>Later the image may be used as a base for a new build, using the
<code>FROM</code> instruction. As part of processing the <code>FROM</code> instruction,
the downstream builder looks for <code>ONBUILD</code> triggers, and executes
them in the same order they were registered. If any of the triggers
fail, the <code>FROM</code> instruction is aborted which in turn causes the
build to fail. If all triggers succeed, the <code>FROM</code> instruction
completes and the build continues as usual.</li><li>Triggers are cleared from the final image after being executed. In
other words they aren't inherited by "grand-children" builds.</li></ol><p>For example you might add something like this:</p><div class="group relative"><button x-data="{ code: 'T05CVUlMRCBBREQgLiAvYXBwL3NyYwpPTkJVSUxEIFJVTiAvdXNyL2xvY2FsL2Jpbi9weXRob24tYnVpbGQgLS1kaXIgL2FwcC9zcmM=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>ONBUILD</span> <span class=k>ADD</span> . /app/src<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ONBUILD</span> <span class=k>RUN</span> /usr/local/bin/python-build --dir /app/src</span></span></code></pre></div></div></div><blockquote class=warning><p><strong>Warning</strong></p><p>Chaining <code>ONBUILD</code> instructions using <code>ONBUILD ONBUILD</code> isn't allowed.</p></blockquote><blockquote class=warning><p><strong>Warning</strong></p><p>The <code>ONBUILD</code> instruction may not trigger <code>FROM</code> or <code>MAINTAINER</code> instructions.</p></blockquote><h2 class=scroll-mt-20 id=stopsignal><a class="text-black dark:text-white no-underline hover:underline" href="index.html#stopsignal">STOPSIGNAL</a></h2><div class="group relative"><button x-data="{ code: 'U1RPUFNJR05BTCBzaWduYWw=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>STOPSIGNAL</span><span class=s> signal</span></span></span></code></pre></div></div></div><p>The <code>STOPSIGNAL</code> instruction sets the system call signal that will be sent to the
container to exit. This signal can be a signal name in the format <code>SIG&lt;NAME></code>,
for instance <code>SIGKILL</code>, or an unsigned number that matches a position in the
kernel's syscall table, for instance <code>9</code>. The default is <code>SIGTERM</code> if not
defined.</p><p>The image's default stopsignal can be overridden per container, using the
<code>--stop-signal</code> flag on <code>docker run</code> and <code>docker create</code>.</p><h2 class=scroll-mt-20 id=healthcheck><a class="text-black dark:text-white no-underline hover:underline" href="index.html#healthcheck">HEALTHCHECK</a></h2><p>The <code>HEALTHCHECK</code> instruction has two forms:</p><ul><li><code>HEALTHCHECK [OPTIONS] CMD command</code> (check container health by running a command inside the container)</li><li><code>HEALTHCHECK NONE</code> (disable any healthcheck inherited from the base image)</li></ul><p>The <code>HEALTHCHECK</code> instruction tells Docker how to test a container to check that
it's still working. This can detect cases such as a web server stuck in
an infinite loop and unable to handle new connections, even though the server
process is still running.</p><p>When a container has a healthcheck specified, it has a health status in
addition to its normal status. This status is initially <code>starting</code>. Whenever a
health check passes, it becomes <code>healthy</code> (whatever state it was previously in).
After a certain number of consecutive failures, it becomes <code>unhealthy</code>.</p><p>The options that can appear before <code>CMD</code> are:</p><ul><li><code>--interval=DURATION</code> (default: <code>30s</code>)</li><li><code>--timeout=DURATION</code> (default: <code>30s</code>)</li><li><code>--start-period=DURATION</code> (default: <code>0s</code>)</li><li><code>--start-interval=DURATION</code> (default: <code>5s</code>)</li><li><code>--retries=N</code> (default: <code>3</code>)</li></ul><p>The health check will first run <strong>interval</strong> seconds after the container is
started, and then again <strong>interval</strong> seconds after each previous check completes.</p><p>If a single run of the check takes longer than <strong>timeout</strong> seconds then the check
is considered to have failed.</p><p>It takes <strong>retries</strong> consecutive failures of the health check for the container
to be considered <code>unhealthy</code>.</p><p><strong>start period</strong> provides initialization time for containers that need time to bootstrap.
Probe failure during that period will not be counted towards the maximum number of retries.
However, if a health check succeeds during the start period, the container is considered
started and all consecutive failures will be counted towards the maximum number of retries.</p><p><strong>start interval</strong> is the time between health checks during the start period.
This option requires Docker Engine version 25.0 or later.</p><p>There can only be one <code>HEALTHCHECK</code> instruction in a Dockerfile. If you list
more than one then only the last <code>HEALTHCHECK</code> will take effect.</p><p>The command after the <code>CMD</code> keyword can be either a shell command (e.g. <code>HEALTHCHECK CMD /bin/check-running</code>) or an exec array (as with other Dockerfile commands;
see e.g. <code>ENTRYPOINT</code> for details).</p><p>The command's exit status indicates the health status of the container.
The possible values are:</p><ul><li>0: success - the container is healthy and ready for use</li><li>1: unhealthy - the container isn't working correctly</li><li>2: reserved - don't use this exit code</li></ul><p>For example, to check every five minutes or so that a web-server is able to
serve the site's main page within three seconds:</p><div class="group relative"><button x-data="{ code: 'SEVBTFRIQ0hFQ0sgLS1pbnRlcnZhbD01bSAtLXRpbWVvdXQ9M3MgXAogIENNRCBjdXJsIC1mIGh0dHA6Ly9sb2NhbGhvc3QvIHx8IGV4aXQgMQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=err>HEALTHCHECK --interval=5m --timeout=3s \
</span></span></span><span class=line><span class=cl><span class=err>  </span><span class=k>CMD</span> curl -f http://localhost/ <span class=o>||</span> <span class=nb>exit</span> <span class=m>1</span></span></span></code></pre></div></div></div><p>To help debug failing probes, any output text (UTF-8 encoded) that the command writes
on stdout or stderr will be stored in the health status and can be queried with
<code>docker inspect</code>. Such output should be kept short (only the first 4096 bytes
are stored currently).</p><p>When the health status of a container changes, a <code>health_status</code> event is
generated with the new status.</p><h2 class=scroll-mt-20 id=shell><a class="text-black dark:text-white no-underline hover:underline" href="index.html#shell">SHELL</a></h2><div class="group relative"><button x-data="{ code: 'U0hFTEwgWyJleGVjdXRhYmxlIiwgInBhcmFtZXRlcnMiXQ==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>SHELL</span> <span class=p>[</span><span class=s2>&#34;executable&#34;</span><span class=p>,</span> <span class=s2>&#34;parameters&#34;</span><span class=p>]</span></span></span></code></pre></div></div></div><p>The <code>SHELL</code> instruction allows the default shell used for the shell form of
commands to be overridden. The default shell on Linux is <code>["/bin/sh", "-c"]</code>, and on
Windows is <code>["cmd", "/S", "/C"]</code>. The <code>SHELL</code> instruction must be written in JSON
form in a Dockerfile.</p><p>The <code>SHELL</code> instruction is particularly useful on Windows where there are
two commonly used and quite different native shells: <code>cmd</code> and <code>powershell</code>, as
well as alternate shells available including <code>sh</code>.</p><p>The <code>SHELL</code> instruction can appear multiple times. Each <code>SHELL</code> instruction overrides
all previous <code>SHELL</code> instructions, and affects all subsequent instructions. For example:</p><div class="group relative"><button x-data="{ code: 'RlJPTSBtaWNyb3NvZnQvd2luZG93c3NlcnZlcmNvcmUKCiMgRXhlY3V0ZWQgYXMgY21kIC9TIC9DIGVjaG8gZGVmYXVsdApSVU4gZWNobyBkZWZhdWx0CgojIEV4ZWN1dGVkIGFzIGNtZCAvUyAvQyBwb3dlcnNoZWxsIC1jb21tYW5kIFdyaXRlLUhvc3QgZGVmYXVsdApSVU4gcG93ZXJzaGVsbCAtY29tbWFuZCBXcml0ZS1Ib3N0IGRlZmF1bHQKCiMgRXhlY3V0ZWQgYXMgcG93ZXJzaGVsbCAtY29tbWFuZCBXcml0ZS1Ib3N0IGhlbGxvClNIRUxMIFsicG93ZXJzaGVsbCIsICItY29tbWFuZCJdClJVTiBXcml0ZS1Ib3N0IGhlbGxvCgojIEV4ZWN1dGVkIGFzIGNtZCAvUyAvQyBlY2hvIGhlbGxvClNIRUxMIFsiY21kIiwgIi9TIiwgIi9DIl0KUlVOIGVjaG8gaGVsbG8=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>FROM</span><span class=s> microsoft/windowsservercore</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C echo default</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> default<span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C powershell -command Write-Host default</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> powershell -command Write-Host default<span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as powershell -command Write-Host hello</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>&#34;powershell&#34;</span><span class=p>,</span> <span class=s2>&#34;-command&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> Write-Host hello<span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c># Executed as cmd /S /C echo hello</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>&#34;cmd&#34;</span><span class=p>,</span> <span class=s2>&#34;/S&#34;</span><span class=p>,</span> <span class=s2>&#34;/C&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=nb>echo</span> hello</span></span></code></pre></div></div></div><p>The following instructions can be affected by the <code>SHELL</code> instruction when the
shell form of them is used in a Dockerfile: <code>RUN</code>, <code>CMD</code> and <code>ENTRYPOINT</code>.</p><p>The following example is a common pattern found on Windows which can be
streamlined by using the <code>SHELL</code> instruction:</p><div class="group relative"><button x-data="{ code: 'UlVOIHBvd2Vyc2hlbGwgLWNvbW1hbmQgRXhlY3V0ZS1NeUNtZGxldCAtcGFyYW0xICJjOlxmb28udHh0Ig==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> powershell -command Execute-MyCmdlet -param1 <span class=s2>&#34;c:\foo.txt&#34;</span></span></span></code></pre></div></div></div><p>The command invoked by the builder will be:</p><div class="group relative"><button x-data="{ code: 'Y21kIC9TIC9DIHBvd2Vyc2hlbGwgLWNvbW1hbmQgRXhlY3V0ZS1NeUNtZGxldCAtcGFyYW0xICJjOlxmb28udHh0Ig==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-powershell data-lang=powershell><span class=line><span class=cl><span class=n>cmd</span> <span class=p>/</span><span class=n>S</span> <span class=p>/</span><span class=n>C</span> <span class=n>powershell</span> <span class=n>-command</span> <span class=nb>Execute-MyCmdlet</span> <span class=n>-param1</span> <span class=s2>&#34;c:\foo.txt&#34;</span></span></span></code></pre></div></div></div><p>This is inefficient for two reasons. First, there is an unnecessary <code>cmd.exe</code>
command processor (aka shell) being invoked. Second, each <code>RUN</code> instruction in
the shell form requires an extra <code>powershell -command</code> prefixing the command.</p><p>To make this more efficient, one of two mechanisms can be employed. One is to
use the JSON form of the <code>RUN</code> command such as:</p><div class="group relative"><button x-data="{ code: 'UlVOIFsicG93ZXJzaGVsbCIsICItY29tbWFuZCIsICJFeGVjdXRlLU15Q21kbGV0IiwgIi1wYXJhbTEgXCJjOlxcZm9vLnR4dFwiIl0=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=k>RUN</span> <span class=o>[</span><span class=s2>&#34;powershell&#34;</span>, <span class=s2>&#34;-command&#34;</span>, <span class=s2>&#34;Execute-MyCmdlet&#34;</span>, <span class=s2>&#34;-param1 \&#34;c:\\foo.txt\&#34;&#34;</span><span class=o>]</span></span></span></code></pre></div></div></div><p>While the JSON form is unambiguous and does not use the unnecessary <code>cmd.exe</code>,
it does require more verbosity through double-quoting and escaping. The alternate
mechanism is to use the <code>SHELL</code> instruction and the shell form,
making a more natural syntax for Windows users, especially when combined with
the <code>escape</code> parser directive:</p><div class="group relative"><button x-data="{ code: 'IyBlc2NhcGU9YAoKRlJPTSBtaWNyb3NvZnQvbmFub3NlcnZlcgpTSEVMTCBbInBvd2Vyc2hlbGwiLCItY29tbWFuZCJdClJVTiBOZXctSXRlbSAtSXRlbVR5cGUgRGlyZWN0b3J5IEM6XEV4YW1wbGUKQUREIEV4ZWN1dGUtTXlDbWRsZXQucHMxIGM6XGV4YW1wbGVcClJVTiBjOlxleGFtcGxlXEV4ZWN1dGUtTXlDbWRsZXQgLXNhbXBsZSAnaGVsbG8gd29ybGQn', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># escape=`</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> microsoft/nanoserver</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>SHELL</span> <span class=p>[</span><span class=s2>&#34;powershell&#34;</span><span class=p>,</span><span class=s2>&#34;-command&#34;</span><span class=p>]</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> New-Item -ItemType Directory C:<span class=se>\E</span>xample<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ADD</span> Execute-MyCmdlet.ps1 c:<span class=se>\e</span>xample<span class=se>\
</span></span></span><span class=line><span class=cl><span class=se></span>RUN c:<span class=se>\e</span>xample<span class=se>\E</span>xecute-MyCmdlet -sample <span class=s1>&#39;hello world&#39;</span></span></span></code></pre></div></div></div><p>Resulting in:</p><div class="group relative"><button x-data="{ code: 'UFMgRTpcbXlwcm9qZWN0PiBkb2NrZXIgYnVpbGQgLXQgc2hlbGwgLgoKU2VuZGluZyBidWlsZCBjb250ZXh0IHRvIERvY2tlciBkYWVtb24gNC4wOTYga0IKU3RlcCAxLzUgOiBGUk9NIG1pY3Jvc29mdC9uYW5vc2VydmVyCiAtLS0+IDIyNzM4ZmY0OWM2ZApTdGVwIDIvNSA6IFNIRUxMIHBvd2Vyc2hlbGwgLWNvbW1hbmQKIC0tLT4gUnVubmluZyBpbiA2ZmNkYjY4NTVhZTIKIC0tLT4gNjMzMTQ2MmQ0MzAwClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgNmZjZGI2ODU1YWUyClN0ZXAgMy81IDogUlVOIE5ldy1JdGVtIC1JdGVtVHlwZSBEaXJlY3RvcnkgQzpcRXhhbXBsZQogLS0tPiBSdW5uaW5nIGluIGQwZWVmODM4NmU5NwoKCiAgICBEaXJlY3Rvcnk6IEM6XAoKCk1vZGUgICAgICAgICBMYXN0V3JpdGVUaW1lICAgICAgICAgICAgICBMZW5ndGggTmFtZQotLS0tICAgICAgICAgLS0tLS0tLS0tLS0tLSAgICAgICAgICAgICAgLS0tLS0tIC0tLS0KZC0tLS0tICAgICAgIDEwLzI4LzIwMTYgIDExOjI2IEFNICAgICAgICAgICAgICBFeGFtcGxlCgoKIC0tLT4gM2YyZmJmMTM5NWQ5ClJlbW92aW5nIGludGVybWVkaWF0ZSBjb250YWluZXIgZDBlZWY4Mzg2ZTk3ClN0ZXAgNC81IDogQUREIEV4ZWN1dGUtTXlDbWRsZXQucHMxIGM6XGV4YW1wbGVcCiAtLS0+IGE5NTViMjYyMWMzMQpSZW1vdmluZyBpbnRlcm1lZGlhdGUgY29udGFpbmVyIGI4MjU1OTNkMzlmYwpTdGVwIDUvNSA6IFJVTiBjOlxleGFtcGxlXEV4ZWN1dGUtTXlDbWRsZXQgJ2hlbGxvIHdvcmxkJwogLS0tPiBSdW5uaW5nIGluIGJlNmQ4ZTYzZmU3NQpoZWxsbyB3b3JsZAogLS0tPiA4ZTU1OWU5YmY0MjQKUmVtb3ZpbmcgaW50ZXJtZWRpYXRlIGNvbnRhaW5lciBiZTZkOGU2M2ZlNzUKU3VjY2Vzc2Z1bGx5IGJ1aWx0IDhlNTU5ZTliZjQyNApQUyBFOlxteXByb2plY3Q+', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=go>PS E:\myproject&gt; docker build -t shell .
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Sending build context to Docker daemon 4.096 kB
</span></span></span><span class=line><span class=cl><span class=go>Step 1/5 : FROM microsoft/nanoserver
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 22738ff49c6d
</span></span></span><span class=line><span class=cl><span class=go>Step 2/5 : SHELL powershell -command
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; Running in 6fcdb6855ae2
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 6331462d4300
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container 6fcdb6855ae2
</span></span></span><span class=line><span class=cl><span class=go>Step 3/5 : RUN New-Item -ItemType Directory C:\Example
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; Running in d0eef8386e97
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>    Directory: C:\
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go>Mode         LastWriteTime              Length Name
</span></span></span><span class=line><span class=cl><span class=go>----         -------------              ------ ----
</span></span></span><span class=line><span class=cl><span class=go>d-----       10/28/2016  11:26 AM              Example
</span></span></span><span class=line><span class=cl><span class=go></span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=go> ---&gt; 3f2fbf1395d9
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container d0eef8386e97
</span></span></span><span class=line><span class=cl><span class=go>Step 4/5 : ADD Execute-MyCmdlet.ps1 c:\example\
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; a955b2621c31
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container b825593d39fc
</span></span></span><span class=line><span class=cl><span class=go>Step 5/5 : RUN c:\example\Execute-MyCmdlet &#39;hello world&#39;
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; Running in be6d8e63fe75
</span></span></span><span class=line><span class=cl><span class=go>hello world
</span></span></span><span class=line><span class=cl><span class=go> ---&gt; 8e559e9bf424
</span></span></span><span class=line><span class=cl><span class=go>Removing intermediate container be6d8e63fe75
</span></span></span><span class=line><span class=cl><span class=go>Successfully built 8e559e9bf424
</span></span></span><span class=line><span class=cl><span class=go>PS E:\myproject&gt;
</span></span></span></code></pre></div></div></div><p>The <code>SHELL</code> instruction could also be used to modify the way in which
a shell operates. For example, using <code>SHELL cmd /S /C /V:ON|OFF</code> on Windows, delayed
environment variable expansion semantics could be modified.</p><p>The <code>SHELL</code> instruction can also be used on Linux should an alternate shell be
required such as <code>zsh</code>, <code>csh</code>, <code>tcsh</code> and others.</p><h2 class=scroll-mt-20 id=here-documents><a class="text-black dark:text-white no-underline hover:underline" href="index.html#here-documents">Here-Documents</a></h2><blockquote><p><strong>Note</strong></p><p>Added in
<a class=link href="index.html#syntax"><code>docker/dockerfile:1.4</code></a></p></blockquote><p>Here-documents allow redirection of subsequent Dockerfile lines to the input of
<code>RUN</code> or <code>COPY</code> commands. If such command contains a
<a class=link href=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 target=_blank rel=noopener>here-document<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a>
the Dockerfile considers the next lines until the line only containing a
here-doc delimiter as part of the same command.</p><h3 class=scroll-mt-20 id=example-running-a-multi-line-script><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-running-a-multi-line-script">Example: Running a multi-line script</a></h3><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGRlYmlhbgpSVU4gPDxFT1QgYmFzaAogIHNldCAtZXgKICBhcHQtZ2V0IHVwZGF0ZQogIGFwdC1nZXQgaW5zdGFsbCAteSB2aW0KRU9U', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> debian</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> &lt;&lt;EOT bash<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  <span class=nb>set</span> -ex<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  apt-get update<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  apt-get install -y vim<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div><p>If the command only contains a here-document, its contents is evaluated with
the default shell.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGRlYmlhbgpSVU4gPDxFT1QKICBta2RpciAtcCBmb28vYmFyCkVPVA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> debian</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> &lt;&lt;EOT<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  mkdir -p foo/bar<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div><p>Alternatively, shebang header can be used to define an interpreter.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIHB5dGhvbjozLjYKUlVOIDw8RU9UCiMhL3Vzci9iaW4vZW52IHB5dGhvbgpwcmludCgiaGVsbG8gd29ybGQiKQpFT1Q=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> python:3.6</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> &lt;&lt;EOT<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=c>#!/usr/bin/env python</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>print<span class=o>(</span><span class=s2>&#34;hello world&#34;</span><span class=o>)</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOT</span></span></code></pre></div></div></div><p>More complex examples may use multiple here-documents.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpSVU4gPDxGSUxFMSBjYXQgPiBmaWxlMSAmJiA8PEZJTEUyIGNhdCA+IGZpbGUyCkkgYW0KZmlyc3QKRklMRTEKSSBhbQpzZWNvbmQKRklMRTI=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>RUN</span> <span class=s>&lt;&lt;FILE1 cat &gt; file1 &amp;&amp; &lt;&lt;FILE</span><span class=m>2</span> cat &gt; file2<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>I am<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>first<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>FILE1<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>I am<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>second<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>FILE2</span></span></code></pre></div></div></div><h3 class=scroll-mt-20 id=example-creating-inline-files><a class="text-black dark:text-white no-underline hover:underline" href="index.html#example-creating-inline-files">Example: Creating inline files</a></h3><p>With <code>COPY</code> instructions, you can replace the source parameter with a here-doc
indicator to write the contents of the here-document directly to a file. The
following example creates a <code>greeting.txt</code> file containing <code>hello world</code> using
a <code>COPY</code> instruction.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpDT1BZIDw8RU9GIGdyZWV0aW5nLnR4dApoZWxsbyB3b3JsZApFT0Y=', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>COPY</span> &lt;&lt;EOF greeting.txt<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>hello world<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOF</span></span></code></pre></div></div></div><p>Regular here-doc
<a class=link href=https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 target=_blank rel=noopener>variable expansion and tab stripping rules<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> apply.
The following example shows a small Dockerfile that creates a <code>hello.sh</code> script
file using a <code>COPY</code> instruction with a here-document.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBUkcgRk9PPWJhcgpDT1BZIDw8LUVPVCAvc2NyaXB0LnNoCiAgZWNobyAiaGVsbG8gJHtGT099IgpFT1QKRU5UUllQT0lOVCBhc2ggL3NjcmlwdC5zaA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>FOO</span><span class=o>=</span>bar
</span></span><span class=line><span class=cl><span class=k>COPY</span> &lt;&lt;-EOT /script.sh<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  <span class=nb>echo</span> <span class=s2>&#34;hello </span><span class=si>${</span><span class=nv>FOO</span><span class=si>}</span><span class=s2>&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOT<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> ash /script.sh</span></span></code></pre></div></div></div><p>In this case, file script prints "hello bar", because the variable is expanded
when the <code>COPY</code> instruction gets executed.</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLXQgaGVyZWRvYyAuCiQgZG9ja2VyIHJ1biBoZXJlZG9jCmhlbGxvIGJhcg==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build -t heredoc .
</span></span><span class=line><span class=cl><span class=gp>$</span> docker run heredoc
</span></span><span class=line><span class=cl><span class=go>hello bar
</span></span></span></code></pre></div></div></div><p>If instead you were to quote any part of the here-document word <code>EOT</code>, the
variable would not be expanded at build-time.</p><div class="group relative"><button x-data="{ code: 'IyBzeW50YXg9ZG9ja2VyL2RvY2tlcmZpbGU6MQpGUk9NIGFscGluZQpBUkcgRk9PPWJhcgpDT1BZIDw8LSJFT1QiIC9zY3JpcHQuc2gKICBlY2hvICJoZWxsbyAke0ZPT30iCkVPVApFTlRSWVBPSU5UIGFzaCAvc2NyaXB0LnNo', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-dockerfile data-lang=dockerfile><span class=line><span class=cl><span class=c># syntax=docker/dockerfile:1</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>FROM</span><span class=s> alpine</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ARG</span> <span class=nv>FOO</span><span class=o>=</span>bar
</span></span><span class=line><span class=cl><span class=k>COPY</span> &lt;&lt;-<span class=s2>&#34;EOT&#34;</span> /script.sh<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>  <span class=nb>echo</span> <span class=s2>&#34;hello </span><span class=si>${</span><span class=nv>FOO</span><span class=si>}</span><span class=s2>&#34;</span><span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span>EOT<span class=err>
</span></span></span><span class=line><span class=cl><span class=err></span><span class=k>ENTRYPOINT</span> ash /script.sh</span></span></code></pre></div></div></div><p>Note that <code>ARG FOO=bar</code> is excessive here, and can be removed. The variable
gets interpreted at runtime, when the script is invoked:</p><div class="group relative"><button x-data="{ code: 'JCBkb2NrZXIgYnVpbGQgLXQgaGVyZWRvYyAuCiQgZG9ja2VyIHJ1biAtZSBGT089d29ybGQgaGVyZWRvYwpoZWxsbyB3b3JsZA==', copying: false }" class="absolute top-3 right-3 text-gray-light-300 dark:text-gray-dark-600" title=Copy @click="window.navigator.clipboard.writeText(atob(code).replaceAll(/^\$\s*/gm, ''));
    copying = true;
    setTimeout(() => copying = false, 2000);">
<span :class="{ 'group-hover:block' : !copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M3e2-2e2q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h440q24 0 42 18t18 42v560q0 24-18 42t-42 18H3e2zM180-80q-24 0-42-18t-18-42v-590q0-13 8.5-21.5T150-760t21.5 8.5T180-730v590h470q13 0 21.5 8.5T680-110t-8.5 21.5T650-80H180z"/></svg></span>
<span :class="{ 'group-hover:block' : copying }" class="hidden icon-svg"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m421-389-98-98q-9-9-22-9t-23 10q-9 9-9 22t9 22l122 123q9 9 21 9t21-9l239-239q10-10 10-23t-10-23q-10-9-23.5-8.5T635-603L421-389zm59 309q-82 0-155-31.5t-127.5-86-86-127.5T80-480q0-83 31.5-156t86-127T325-848.5 480-880q83 0 156 31.5T763-763t85.5 127T880-480q0 82-31.5 155T763-197.5t-127 86T480-80z"/></svg></span></button><div class="syntax-light dark:syntax-dark"><div class=highlight><pre tabindex=0 class=chroma><code class=language-console data-lang=console><span class=line><span class=cl><span class=gp>$</span> docker build -t heredoc .
</span></span><span class=line><span class=cl><span class=gp>$</span> docker run -e <span class=nv>FOO</span><span class=o>=</span>world heredoc
</span></span><span class=line><span class=cl><span class=go>hello world
</span></span></span></code></pre></div></div></div><h2 class=scroll-mt-20 id=dockerfile-examples><a class="text-black dark:text-white no-underline hover:underline" href="index.html#dockerfile-examples">Dockerfile examples</a></h2><p>For examples of Dockerfiles, refer to:</p><ul><li>The
<a class=link href="../../userguide/eng-image/dockerfile_best-practices/index.html" target=_blank rel=noopener>"build images" section<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a></li><li>The
<a class=link href="../../../get-started/index.html" target=_blank rel=noopener>"get started" tutorial<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a></li><li>The
<a class=link href="../../../language/index.html" target=_blank rel=noopener>language-specific getting started guides<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a></li><li>The
<a class=link href="../../../build/guide/index.html" target=_blank rel=noopener>build guide<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a></li></ul><div class=footnotes role=doc-endnotes><hr><ol><li id=fn:1><p>Value required&#160;<a href="index.html#fnref:1" class=footnote-backref role=doc-backlink>&#8617;&#xfe0e;</a>&#160;<a href="index.html#fnref1:1" class=footnote-backref role=doc-backlink>&#8617;&#xfe0e;</a>&#160;<a href="index.html#fnref2:1" class=footnote-backref role=doc-backlink>&#8617;&#xfe0e;</a></p></li><li id=fn:2><p>For Docker-integrated
<a class=link href="../../../build/buildkit/index.html#getting-started" target=_blank rel=noopener>BuildKit<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a> and <code>docker buildx build</code>&#160;<a href="index.html#fnref:2" class=footnote-backref role=doc-backlink>&#8617;&#xfe0e;</a></p></li></ol></div></article></div><div class="sticky top-16 h-screen w-[300px] shrink grow overflow-y-scroll lg:hidden"><aside class="py-4 space-y-4"><p class="flex items-center gap-2"><span class=icon-svg><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="m378-332 363-363q9.067-9 21.533-9Q775-704 784-694.947q9 9.052 9 21.5Q793-661 784-652L399-267q-9 9-21 9t-21-9L175-449q-9-9.067-8.5-21.533Q167-483 176.053-492q9.052-9 21.5-9Q210-501 219-492l159 160z"/></svg></span>
<a class=link target=_blank rel=noopener href="https://github.com/docker/docs/issues/new?template=doc_issue.yml&location=https%3a%2f%2fdocs.docker.com%2freference%2fdockerfile%2f&labels=status%2Ftriage">Request changes
<span class="icon-svg icon-xs icon-top"><svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 -960 960 960"><path d="M180-120q-24 0-42-18t-18-42v-6e2q0-24 18-42t42-18h249q12.75.0 21.375 8.675 8.625 8.676 8.625 21.5.0 12.825-8.625 21.325T429-780H180v6e2h6e2v-249q0-12.75 8.675-21.375 8.676-8.625 21.5-8.625 12.825.0 21.325 8.625T840-429v249q0 24-18 42t-42 18H180zm6e2-617L403-360q-9 9-21 8.5t-21-9.5-9-21 9-21l377-377H549q-12.75.0-21.375-8.675-8.625-8.676-8.625-21.5.0-12.825 8.625-21.325T549-840h291v291q0 12.75-8.675 21.375-8.676 8.625-21.5 8.625-12.825.0-21.325-8.625T780-549v-188z"/></svg></span></a></a></p><div><div class="text-lg pb-2">Contents</div><nav id=TableOfContents><ul><li><a href="index.html#overview">Overview</a></li><li><a href="index.html#format">Format</a></li><li><a href="index.html#parser-directives">Parser directives</a><ul><li><a href="index.html#syntax">syntax</a></li><li><a href="index.html#escape">escape</a></li></ul></li><li><a href="index.html#environment-replacement">Environment replacement</a></li><li><a href="index.html#dockerignore-file">.dockerignore file</a></li><li><a href="index.html#shell-and-exec-form">Shell and exec form</a><ul><li><a href="index.html#exec-form">Exec form</a></li><li><a href="index.html#shell-form">Shell form</a></li><li><a href="index.html#use-a-different-shell">Use a different shell</a></li></ul></li><li><a href="index.html#from">FROM</a><ul><li><a href="index.html#understand-how-arg-and-from-interact">Understand how ARG and FROM interact</a></li></ul></li><li><a href="index.html#run">RUN</a><ul><li><a href="index.html#cache-invalidation-for-run-instructions">Cache invalidation for RUN instructions</a></li></ul></li><li><a href="index.html#run---mount">RUN --mount</a><ul><li><a href="index.html#mount-types">Mount types</a></li><li><a href="index.html#run---mounttypebind">RUN --mount=type=bind</a></li><li><a href="index.html#run---mounttypecache">RUN --mount=type=cache</a></li><li><a href="index.html#run---mounttypetmpfs">RUN --mount=type=tmpfs</a></li><li><a href="index.html#run---mounttypesecret">RUN --mount=type=secret</a></li><li><a href="index.html#run---mounttypessh">RUN --mount=type=ssh</a></li></ul></li><li><a href="index.html#run---network">RUN --network</a><ul><li><a href="index.html#network-types">Network types</a></li><li><a href="index.html#run---networkdefault">RUN --network=default</a></li><li><a href="index.html#run---networknone">RUN --network=none</a></li><li><a href="index.html#run---networkhost">RUN --network=host</a></li></ul></li><li><a href="index.html#run---security">RUN --security</a><ul><li><a href="index.html#run---securityinsecure">RUN --security=insecure</a></li><li><a href="index.html#run---securitysandbox">RUN --security=sandbox</a></li></ul></li><li><a href="index.html#cmd">CMD</a></li><li><a href="index.html#label">LABEL</a></li><li><a href="index.html#maintainer-deprecated">MAINTAINER (deprecated)</a></li><li><a href="index.html#expose">EXPOSE</a></li><li><a href="index.html#env">ENV</a></li><li><a href="index.html#add">ADD</a><ul><li><a href="index.html#verifying-a-remote-file-checksum-add---checksumchecksum-http-src-dest">Verifying a remote file checksum <code>ADD --checksum=&lt;checksum> &lt;http src> &lt;dest></code></a></li><li><a href="index.html#adding-a-git-repository-add-git-ref-dir">Adding a Git repository <code>ADD &lt;git ref> &lt;dir></code></a></li><li><a href="index.html#adding-a-private-git-repository">Adding a private git repository</a></li></ul></li><li><a href="index.html#add---link">ADD --link</a></li><li><a href="index.html#copy">COPY</a></li><li><a href="index.html#copy---link">COPY --link</a><ul><li><a href="index.html#benefits-of-using---link">Benefits of using <code>--link</code></a></li><li><a href="index.html#incompatibilities-with---linkfalse">Incompatibilities with <code>--link=false</code></a></li></ul></li><li><a href="index.html#copy---parents">COPY --parents</a></li><li><a href="index.html#entrypoint">ENTRYPOINT</a><ul><li><a href="index.html#exec-form-entrypoint-example">Exec form ENTRYPOINT example</a></li><li><a href="index.html#shell-form-entrypoint-example">Shell form ENTRYPOINT example</a></li><li><a href="index.html#understand-how-cmd-and-entrypoint-interact">Understand how CMD and ENTRYPOINT interact</a></li></ul></li><li><a href="index.html#volume">VOLUME</a><ul><li><a href="index.html#notes-about-specifying-volumes">Notes about specifying volumes</a></li></ul></li><li><a href="index.html#user">USER</a></li><li><a href="index.html#workdir">WORKDIR</a></li><li><a href="index.html#arg">ARG</a><ul><li><a href="index.html#default-values">Default values</a></li><li><a href="index.html#scope">Scope</a></li><li><a href="index.html#using-arg-variables">Using ARG variables</a></li><li><a href="index.html#predefined-args">Predefined ARGs</a></li><li><a href="index.html#automatic-platform-args-in-the-global-scope">Automatic platform ARGs in the global scope</a></li><li><a href="index.html#buildkit-built-in-build-args">BuildKit built-in build args</a></li><li><a href="index.html#impact-on-build-caching">Impact on build caching</a></li></ul></li><li><a href="index.html#onbuild">ONBUILD</a></li><li><a href="index.html#stopsignal">STOPSIGNAL</a></li><li><a href="index.html#healthcheck">HEALTHCHECK</a></li><li><a href="index.html#shell">SHELL</a></li><li><a href="index.html#here-documents">Here-Documents</a><ul><li><a href="index.html#example-running-a-multi-line-script">Example: Running a multi-line script</a></li><li><a href="index.html#example-creating-inline-files">Example: Creating inline files</a></li></ul></li><li><a href="index.html#dockerfile-examples">Dockerfile examples</a></li></ul></nav></div></aside></div></main><footer><div class="flex justify-center py-20 px-4 bg-gray-light-200/50 dark:bg-gray-dark-300/50"><div class="flex w-[1200px] flex-col gap-10"><div class="flex sm:flex-col gap-4 items-center justify-evenly"><a class="underline-offset-2 hover:underline" href=https://www.docker.com/>Product offerings</a>
<a class="underline-offset-2 hover:underline" href=https://www.docker.com/pricing/>Pricing</a>
<a class="underline-offset-2 hover:underline" href=https://www.docker.com/company/>About us</a>
<a class="underline-offset-2 hover:underline" href=https://www.docker.com/support/>Support</a>
<a class="underline-offset-2 hover:underline" href=https://github.com/docker/docs/blob/main/CONTRIBUTING.md>Contribute</a></div><hr class="text-divider-light dark:text-divider-dark"><div class="grid grid-cols-3 place-items-center gap-8 md:grid-cols-1"><p class=text-sm>Copyright © 2013-2024 Docker Inc. All rights reserved.</p><div class="flex gap-4"><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title="X (Twitter)" href=http://twitter.com/docker/><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 29 29"><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M14.62 13.41l-3.3-4.62H9.56l4.09 5.72.51.72 3.51 4.91h1.76l-4.29-6.01-.52-.72z"/><path class="cls-1" d="M14.5.0A14.5 14.5.0 1029 14.5 14.5 14.5.0 0014.5.0zm2.63 20.94-3.55-5.05-4.43 5.05H8l5.07-5.77L8 7.94h3.87l3.36 4.78 4.2-4.78h1.15l-4.84 5.51L21 20.94z"/></g></g></svg>
</a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=LinkedIn href=https://www.linkedin.com/company/docker><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zM8.176 9.66H5.174v9.035h3.002V9.66zm-3.18-2.795c0-.885.671-1.56 1.699-1.56 1.027.0 1.66.675 1.679 1.56.0.867-.652 1.562-1.7 1.562h-.018c-1.008.0-1.66-.695-1.66-1.562zm7.845 4.074c.398-.614 1.112-1.49 2.706-1.49 1.976.0 3.457 1.29 3.457 4.065v5.18h-3.002v-4.833c0-1.214-.435-2.043-1.522-2.043-.829.0-1.323.559-1.54 1.098-.08.194-.099.463-.099.733v5.046H9.838s.04-8.187.0-9.035h3.003v1.28z"/></svg>
</a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=Instagram href=https://www.instagram.com/dockerinc/><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zM6.984 4.774c.485-.19 1.04-.32 1.853-.359.814-.039 1.074-.048 3.148-.052 2.075-.004 2.335.004 3.15.04.812.035 1.368.164 1.853.352.503.193.93.454 1.355.878s.687.849.883 1.35c.19.486.32 1.041.359 1.854.038.815.048 1.074.052 3.148s-.005 2.335-.04 3.15c-.036.812-.164 1.368-.352 1.854a3.737 3.737.0 01-.878 1.354 3.746 3.746.0 01-1.35.884c-.486.19-1.04.32-1.853.358-.815.039-1.075.048-3.15.052-2.073.004-2.333-.004-3.148-.04-.813-.036-1.369-.163-1.854-.351a3.746 3.746.0 01-1.355-.878 3.74 3.74.0 01-.883-1.352c-.19-.485-.32-1.04-.359-1.852-.039-.815-.048-1.075-.052-3.15-.004-2.073.004-2.333.04-3.148.036-.813.163-1.368.351-1.855.195-.502.455-.929.879-1.354a3.736 3.736.0 011.35-.883zm.523 13.189c.27.103.674.227 1.419.26.806.034 1.047.042 3.086.038 2.04-.004 2.28-.012 3.086-.05.744-.036 1.148-.16 1.417-.266.357-.14.61-.306.877-.573.267-.268.432-.522.57-.879.104-.27.228-.674.26-1.419.035-.805.043-1.047.039-3.086-.004-2.039-.012-2.28-.05-3.086-.036-.744-.16-1.149-.266-1.417a2.366 2.366.0 00-.573-.878 2.364 2.364.0 00-.88-.57c-.269-.103-.674-.227-1.418-.26-.805-.034-1.047-.042-3.086-.038-2.04.004-2.28.012-3.086.05-.744.036-1.148.16-1.417.266a2.38 2.38.0 00-.878.573 2.37 2.37.0 00-.57.88c-.103.269-.227.674-.26 1.418-.034.805-.042 1.047-.038 3.086.004 2.04.013 2.28.05 3.086.035.744.161 1.148.266 1.418.14.356.305.61.573.877.268.266.522.431.88.57zm8.563-9.131a.917.917.0 11-.003-1.833.917.917.0 01.003 1.833zm-4.063 7.09a3.921 3.921.0 11-.015-7.843 3.921 3.921.0 01.015 7.842zm-.012-6.468a2.546 2.546.0 10.01 5.092 2.546 2.546.0 00-.01-5.092z"/></svg>
</a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=YouTube href=http://www.youtube.com/user/dockerrun><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 24c6.627.0 12-5.373 12-12S18.627.0 12 0 0 5.373.0 12s5.373 12 12 12zm7.543-15.79a1.971 1.971.0 00-1.392-1.39C16.923 6.49 12 6.49 12 6.49s-4.924.0-6.152.33A1.972 1.972.0 004.457 8.21c-.33 1.229-.33 3.79-.33 3.79s0 2.562.33 3.79c.18.677.714 1.21 1.391 1.391 1.228.329 6.151.329 6.151.329s4.923.0 6.15-.329a1.972 1.972.0 001.393-1.392c.329-1.227.329-3.789.329-3.789s0-2.561-.33-3.79zm-9.117 6.151L14.516 12l-4.09-2.361v4.722z"/></svg>
</a><a class="h-8 w-8 rounded-full fill-blue-light dark:fill-blue-dark" title=Facebook href=https://www.facebook.com/docker.run><svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M13.54 24c5.948-.736 10.552-5.807 10.552-11.954C24.092 5.393 18.699.0 12.046.0S0 5.393.0 12.046c0 5.842 4.158 10.712 9.677 11.813v-8.374H6.538v-3.573h3.139V9.188c0-3.098 1.845-4.81 4.669-4.81 1.352.0 2.767.242 2.767.242v3.042h-1.559c-1.536.0-2.014.953-2.014 1.93v2.32h3.428l-.548 3.573h-2.88V24z"/></svg></a></div><div class="flex items-center gap-4"><a class="underline-offset-2 hover:underline" title="Docker Terms of Service" href=https://www.docker.com/legal/docker-terms-service>Terms of Service</a>
<a class="underline-offset-2 hover:underline" title="Docker Systems Status Page" href=https://www.dockerstatus.com/>Status</a>
<a class="underline-offset-2 hover:underline" title="Docker Legal Terms" href=https://www.docker.com/legal>Legal</a></div></div></div></div></footer></body></html>